Debug a Failing Test
Workflow for diagnosing why a test is failing
CLAUDE.md
When debugging a failing test:
- Read the test failure output: expected vs actual values, error messages, stack traces.
- Run the test in isolation to confirm it fails independently (not due to test order).
- Read the test code to understand what it expects.
- Read the implementation code the test exercises.
- If the test expectation is correct and the code is wrong, fix the code.
- If the code is correct and the test is outdated, update the test.
- If the failure is intermittent, investigate flakiness: timing issues, shared state, external dependencies.
Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.