Write Tests
Steps
- •
Identify what to test:
- •If
$ARGUMENTSis a file path → test that file - •If
$ARGUMENTSis "recent" or empty → checkgit diff HEAD~3 --name-onlyfor recently changed files
- •If
- •
Read the source code and identify testable behavior:
- •Business logic functions (HIGH priority)
- •API endpoints / server actions (HIGH priority)
- •Utility functions (MEDIUM priority)
- •Component interactions (MEDIUM priority)
- •Pure rendering (LOW — skip unless asked)
- •
Check existing test patterns in the project:
- •Find existing test files:
*.test.ts,*.spec.ts,__tests__/ - •Match the project's test framework (Jest, Vitest, Playwright)
- •Follow existing naming and file placement conventions
- •Find existing test files:
- •
Write tests that verify behavior, not implementation:
- •Test inputs → outputs, not internal details
- •Test edge cases: null, empty, boundary values
- •Test error paths (invalid input, missing data)
- •For financial code: use EXACT expected values, never approximate
- •
Run the tests to confirm they pass
- •
Report:
codeWrote N tests in M files: - path/to/test.ts — what's tested
Rules
- •Match the project's existing test style exactly
- •Never mock what you can use directly
- •Test behavior, not implementation details
- •Financial assertions must use exact values (no toBeCloseTo)