shinpr/frontend-typescript-testing
Designs frontend tests using the repository's configured React test and browser harnesses, including RTL, MSW, Vitest, and Playwright when present. Use when adding or reviewing component, loading/error-state, integration, or frontend E2E tests.
npx skills add https://github.com/shinpr/ai-coding-project-boilerplate --skill frontend-typescript-testing
Inspect package.json, the lockfile, test configuration, and existing test imports before selecting a framework or command. Apply Vitest, React Testing Library, MSW, or Playwright rules only when the dependency/configuration is present. Use the repository's configured equivalent when different. If no runnable harness can be identified, report the inspected paths and the missing framework or command instead of inventing one.
| Test Type | Reference | When to Use |
|-----------|-----------|-------------|
| Unit / Integration | This document | Implementing React component tests with RTL + Vitest + MSW |
| E2E | references/e2e.md | Implementing browser-level E2E tests with Playwright |
import { describe, it, expect, beforeEach, vi } from 'vitest'import { render, screen } from '@testing-library/react'import userEvent from '@testing-library/user-event'vi.mock()For shared components, custom hooks, and utilities reused across features, cover their public branches, error states, and boundary contracts because their regression blast radius is wider. Verify page-level composition through integration/E2E tests when the behavior depends on multiple rendered units.
{ComponentName}.test.tsx{FeatureName}.integration.test.tsxKeep every committed test active. Repair a test that protects current behavior; remove a test only when its behavior is no longer required and the source requirement or implementation contract confirms the removal.
Constrain an MSW handler's response body with satisfies against the domain type it stands for, so a fixture that drifts from the contract fails at compile time rather than producing a passing test against a shape the app never receives.
Type a component or dependency mock to the surface the subject under test actually consumes — Pick<Props, 'usedProp'>, Pick<Router, 'push'> — rather than the full interface, and constrain the literal with satisfies so an extra or misnamed member fails at compile time.
Test user-visible results, not implementation details. Query by the role and accessible name the user perceives (getByRole/getByLabelText/getByText), not getByTestId or container.querySelector. Drive interactions through userEvent with userEvent.setup() per test rather than firing raw events, so the test reproduces the browser's event sequence. await every interaction and async assertion — an unawaited interaction asserts against the pre-update render, so use findBy* for async UI.
Cover empty, error, and loading/async states, not only the happy path. Produce an error state by overriding the MSW handler for that single test rather than changing the shared handler set.
When the required UI state, accessibility name, or external contract is unknown, stop test design for that assertion and name the UI Spec, acceptance criterion, implementation contract, or user decision needed. Continue with independent assertions whose expected behavior is observed.
Take shinpr/frontend-typescript-testing from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.