- name
- frontend-typescript-testing
- description
- 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.
TypeScript Testing Rules (Frontend)
Prerequisite Detection
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.
References
Test Framework
- Vitest: Use when the repository config or existing tests select Vitest
- React Testing Library: For component testing
- MSW (Mock Service Worker): For API mocking
- Test imports:
import { describe, it, expect, beforeEach, vi } from 'vitest' - Component test imports:
import { render, screen } from '@testing-library/react' - User interaction:
import userEvent from '@testing-library/user-event' - Mock creation: Use
vi.mock()
Basic Testing Policy
Quality Requirements
- Regression protection: assert the named acceptance result, public branch, or failure state on critical paths and high-reuse components
- Independence: Each test can run independently without depending on other tests