| name | testing |
| description | Write and maintain tests with Vitest v4 dual configuration, mock utilities, and Zustand store testing patterns. |
Testing
Write reliable tests with Vitest v4 dual configuration.
Activation Conditions
- Writing or modifying tests
- Debugging test failures
- Setting up mocks
- Questions about test configuration
Quick Reference
| Action | Rule |
|---|
| Choose test type | test-unit-vs-integration.md |
| Mock modules | test-mock-patterns.md |
| Test stores | test-zustand-stores.md |
| Mock Connect APIs | mock-transport.md |
| Skip UI rendering tests | no-ui-rendering-tests.md |
Commands
bun run test
bun run test:ci
bun run test:unit
bun run test:integration
bun run test:ui
bun run test:watch
bun run test:coverage
Key Points
.test.ts = unit (Node.js), .test.tsx = integration (JSDOM)
- Always use
test-utils/test-utils.tsx for React component tests
- Test that features are fully wired: UI elements must connect to actual functionality
Feature Completeness Testing
When implementing interactive features (buttons, forms, etc.):
- Verify event handlers call the correct functions with proper parameters
- Test that AbortSignals, callbacks, and other "plumbing" are passed through
- Don't assume UI presence means functionality works - test the connection
When to Use This Skill
- Writing
.test.ts or .test.tsx files
- Mocking modules, stores, or transports
- Component behavior tests
NOT for: Multi-page user workflows → use e2e-tester
Rules
See rules/ directory for detailed guidance.