| name | fix-tests |
| description | Systematic workflow for diagnosing and fixing failing tests. Use when the user reports failing tests or asks to fix test failures. |
Skill: Fix Failing Tests
Trigger
When the user reports failing tests or asks to fix test failures.
Prerequisites
Steps
Step 1: Identify Failing Tests
Step 2: Analyze Each Failure
For each failing test:
Step 3: Common Fix Patterns
Mock Issues
- Mock not returning expected value → Update mock return
- Mock not being called → Check import path
- Mock state leaking → Add
beforeEach reset
Assertion Issues
- Expected value changed → Update test or fix code
- Async not awaited → Add
await or use waitFor
- Wrong matcher → Use correct Jest matcher
Type Issues
- Interface changed → Update test data
- New required field → Add to test factories
- Return type changed → Update assertions
Step 4: Fix Tests
Step 5: Verify
Completion Checklist
If Step Fails
- Step 1 (identify): Run
{{CONFIG.testing.testCommand}} — if it hangs, run single file with --testPathPattern=path/to/file
- Step 2 (analyze): Mock issues often from wrong import path; use
jest.mock('./path') matching actual import
- Step 4 (fix): Fix one test, run
--testPathPattern to verify, then next. Don't fix all at once
- Step 5 (verify): If coverage dropped, add test for uncovered branch. Use
@coverage-improvement skill
Example
Failure: "Expected 60, received undefined". Cause: mock for calculateTotal not returning. Fix: mockCalculateTotal.mockReturnValue(60) in test. Run: npm test -- order.test.ts.