Skip to content
Back to skills

Flaky Test Investigation

ASecurity

Use to diagnose tests that pass and fail intermittently without code changes.

  • 6 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 29, 2026
ai-agentsrustdatabase

Security analysis

A100/100

Scanned May 29, 2026

npx -y skills add yeaight7/agent-powerups --skill flaky-test-investigation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Flaky Test Investigation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Flaky Test Investigation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/yeaight7-flaky-test-investigation/badge)](https://www.skillsdirectory.com/skills/yeaight7-flaky-test-investigation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: flaky-test-investigation
description: "Use to diagnose tests that pass and fail intermittently without code changes."
---

# Flaky Test Investigation

Flaky tests erode trust in CI. Do not just re-run them and hope for the best.

## Investigation Protocol

1. **Isolate the Test**: Run the specific failing test by itself. If it passes, the flake is likely an **order dependency** or **state leakage** from a previous test.
2. **Stress Test**: Run the test in a tight loop (e.g., `for i in {1..100}; do npm test -- -t "My Test"; done`).
3. **Check for Common Vectors**:
   - **Time**: Does the test rely on `Date.now()` or `setTimeout`? Mock the clock.
   - **Async/Promises**: Are we asserting before a background task finishes? Ensure proper `await` or `waitFor` usage.
   - **Shared State**: Are we reusing database records, global singletons, or mutated variables between runs? Ensure clean teardowns in `afterEach`.
   - **Randomness**: Does the test rely on random IDs or sorts? Force deterministic seeds or sort orders.
4. **Prove the Fix**: Do not just guess. The fix must be verified by running the stress test loop again and achieving a 100% pass rate.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.