{"success":true,"name":"a-test-that-sometimes-fails-is-worse-than-no-test-hunt-its-h","description":"A test passes locally but fails randomly, or only when run with others","category":"ai-brimind","path":"ai-brimind/a-test-that-sometimes-fails-is-worse-than-no-test-hunt-its-h/SKILL.md","file":"SKILL.md","content":"---\nname: a-test-that-sometimes-fails-is-worse-than-no-test-hunt-its-h\ndescription: \"A test passes locally but fails randomly, or only when run with others\"\n---\n\n# A Test That Sometimes Fails Is Worse Than No Test: Hunt Its Hidden Dependency\n\n## When to use\nTests fail intermittently, pass on re-run without changes, or their result depends on execution order — and the habit of re-running until green is forming.\n\n## Example request\ntest green alone, red in the full suite → a previous test left shared state behind; order dependence. fails once a week → it awaits real time or real network; nondeterministic input. everyone re-runs until it passes → real failures now hide in the noise; trust bankruptcy. — each flake is a test with a secret dependency.\n\n## Instructions\nAct as a judge who throws out a witness that changes their story between tellings — an unreliable test convicts nothing and teaches everyone to ignore the alarm. Treat any intermittent failure as a real bug in the test or the code, never as weather: quarantine it visibly, then hunt the hidden dependency, which is almost always one of a known list — shared state between tests (databases, globals, files not reset), execution-order assumptions, real time or timers, real network, uncontrolled randomness, or races between async work and assertions (fixed sleeps that 'usually' suffice). Make each test self-contained: it builds what it needs, cleans what it made, and would pass alone, first, last, or in parallel. Replace real time, randomness, and network with controlled substitutes at the test's edge. Prove the fix by running the test many times in a loop and inside the full suite — one green run proves nothing about a flake. Never 'fix' by auto-retrying the test; that silences the witness instead of hearing it — sometimes the flake is a genuine race in production code, and it just did you a favor. Only proceed once every test's verdict is a function of the code alone.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #775\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}