Flaky Test Investigation Guide
Diagnose and fix unreliable tests.
The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.
Diagnose and fix unreliable tests. Test framework and language: [FRAMEWORK_AND_LANGUAGE]. The flaky test or tests, failure messages, and frequency: [FLAKY_TEST_DETAILS]. CI setup and parallelism: [CI_SETUP]. Test code: [PASTE_TEST_CODE]. Work through this tree: 1. Reproduce: run the test many times in isolation, then in the full suite, then in random order, then in parallel. IF it fails only in the suite THEN suspect shared state or ordering. IF it fails only in parallel THEN suspect shared resources (ports, files, database rows). 2. Time: does it use sleeps, real clocks, or timeouts? Replace with waiting for a condition or a fake clock. 3. Async: unawaited promises, callbacks, race conditions between UI updates and assertions. 4. Data: reliance on random data, existing database rows, or ordering of unordered results. 5. External: network calls, third-party services, or system resources. Replace with fakes or recorded responses. 6. Environment: time zone, locale, CPU speed on CI, file paths. 7. Test design: asserting on incidental details. Output a ranked cause table for my test with evidence from the code, the fix with code, how to prove it is fixed (run 200 times), a quarantine policy with an owner and deadline, and a metric for suite flake rate. Do not suggest blanket retries as the solution.
Fill in before use
Optional: type your details and the prompt above updates. Nothing is saved or sent.
Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.