debug-failing-test

Diagnose failing unit tests through iterative logging, fixing, and cleanup.

1|Updated Aug 31, 2026
One-click install
npx skills add https://github.com/nguyenhungtran18/skill-and-tool-tracker --skill debug-failing-test-nguyenhungtran18
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: debug-failing-test
Source: https://github.com/nguyenhungtran18/skill-and-tool-tracker/tree/main/skills/debug-failing-test
Command: npx skills add https://github.com/nguyenhungtran18/skill-and-tool-tracker --skill debug-failing-test-nguyenhungtran18

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Failing tests with unclear error messages waste developer time when the root cause is hidden in intermediate state, async timing, or misconfigured mocks. This Skill provides a structured, repeatable workflow for isolating the failure instead of guessing. ## Core Features & Use Cases - Iterative Logging Loop: Adds targeted console.log('[DEBUG]', ...) statements around suspicious code, runs the test, and narrows down the divergence step by step. - Fix and Regression Verification: Implements the fix, re-runs the failing test, and checks related tests to prevent regressions. - Cleanup and Learning Capture: Removes all debug artifacts and records a reusable learning in the relevant instruction file. - Use Case: A unit test for an environment manager fails with an unexpected empty array. The Skill logs inputs and outputs around the call, reveals a mock returning stale data, fixes the mock setup, and cleans up all logging. ## Quick Start Debug my failing unit test using the iterative logging approach and tell me the root cause and fix.

Frequently Asked Questions about debug-failing-test

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I debug a failing unit test with unclear errors?▼

Add targeted console.log statements with a [DEBUG] label around the suspicious code, run the test, and compare logged values against expectations. Repeat with narrower logging until the divergence point reveals the root cause, then fix and remove all debug statements.

How to find the root cause of a test assertion failure?▼

Start at the failing assertion and work backwards through the values it compares. Log inputs, intermediate states, and return values before and after key operations to locate where actual behavior diverges from expected behavior.

Why does my test fail only because of mock setup?▼

Tests often fail because mocks return unexpected values or are not reset between cases. Log the mock return values during the test run and verify the setup and teardown code configures them as the source code expects.

Can this approach debug async timing and race condition test failures?▼

Yes, add timestamps to debug logs when timing might be relevant and log before and after awaited operations. Comparing the order and timing of logged events exposes race conditions and unhandled promises.

What should I do after fixing a failing test?▼

Remove every debug log and temporary variable added during diagnosis, then re-run the test and related tests to confirm no regressions. Finally, summarize the bug and fix, and record the learning in the relevant instruction file.