Debugging Failing Tests
When a test fails, follow this sequence before giving up:
- •Understand the test — read its name and body to know exactly which behaviour it verifies.
- •Walk the call stack — trace backwards from the failure to find the function responsible.
- •Verify inputs — confirm the failing function receives the values you expect.
- •Add instrumentation — insert temporary
print/console.log/dbg!statements to:- •Pinpoint the branch or condition that diverges from the expected path.
- •Identify the exact variable and the moment its value departs from what is correct.
- •Escalate if stuck — if the above steps don't lead to a fix, stop and present a structured report to the user containing:
- •Test name
- •Full error message and stack trace
- •Inputs passed to the failing function
- •Observed value vs. expected value
- •Any additional observations
- •Link to an issue when appropriate — if the failure relates to work tracked in a GitHub issue (check the branch name for a clue), post the report as a comment on that issue. Otherwise, display it directly.