| name | frontend-testing-patterns |
| description | Provides comprehensive testing strategies and patterns for React applications. This skill should be used when writing tests, setting up testing infrastructure, or deciding what to test. |
Frontend Testing Patterns
Testing patterns for React applications. Test runner: Vitest (not Jest).
See references/testing-examples.md for detailed code examples.
Canonical Examples
Testing Pyramid
E2E Tests (Few) ← Playwright
Integration Tests (Some) ← React Testing Library
Unit Tests (Many) ← Vitest
Key Rules
- Use
screen queries (not destructured getBy*)
- Test user behavior, not implementation
- Use
userEvent for interactions (not fireEvent)
- Use
waitFor/findBy* for async operations
- Mock APIs with MSW (
setupServer)
- Wrap hooks in
QueryClientProvider via createWrapper()
What to Test / Skip
| ✅ Test | ❌ Skip |
|---|
| User interactions | Implementation details |
| Conditional rendering (loading/error/empty) | Third-party internals |
| Accessibility (ARIA, keyboard) | Styling |
| Hook + context integration | Trivial code |
| Edge cases and errors | |
| Route search-param behavior | |
Refactor Parity Suite
When decomposing a large route component, verify:
- Loading/empty/data states unchanged
- Search-param behavior preserved
- Pagination clamping only after data available
- Route actions still update URL state correctly
Checklist
Related Skills