| name | testing-requirements |
| description | Use when writing tests - test structure, verification steps, coverage goals |
Testing Requirements
Use this skill when implementing features that need testing or modifying existing tests.
Checklist
Test Framework Setup
Test Structure
Common Testing Patterns
Socket Events - Capture handlers:
let handlers: Record<string, (data: unknown) => void> = {}
vi.mock('@/cores/sockets', () => ({
useSocketEvent: (event, handler) => (handlers[event] = handler)
}))
handlers[SocketEvents.DOWNLOAD_START]({ id: 'model-123' })
Zustand Stores:
import { renderHook, act } from '@testing-library/react'
import { useMyStore } from './useMyStore'
const { result } = renderHook(() => useMyStore())
act(() => result.current.setValue('new'))
React Query:
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
const queryClient = new QueryClient()
const wrapper = ({ children }) => (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
)
render(<MyComponent />, { wrapper })
Coverage Goals
Pre-Completion Verification
Before marking work complete, ALWAYS run:
Testing Anti-Patterns to Avoid
❌ Don't test implementation details
- Example: Testing that
socket.on was called 3 times
- Instead: Test that component responds correctly to events
❌ Don't use any type in tests
- Use proper types,
unknown, or as unknown as Type
❌ Don't skip cleanup
- Always reset Zustand stores in
beforeEach
- Clear mocks between tests