PhraseryPhrasery homeGet Phrasery
Tests & QA21 categories

Make this flaky test deterministic

A test that passes locally and fails in CI roughly one run in ten.

Longflakydebuggingci
This test is flaky. Find the source of non-determinism.

Work through, in order:
- Time: real clocks, timeouts, sleeps, date boundaries, timezones, daylight saving.
- Ordering: test execution order, shared state between tests, iteration over unordered collections.
- Concurrency: async work not awaited, background jobs, connection pools.
- External dependencies: network, filesystem, ports, containers not yet ready.
- Data: random generators, auto-increment IDs, leftover records from a previous run.
- Environment: CI machine slower, fewer cores, different locale.

For each candidate, state the exact mechanism that produces the intermittent failure. Then give the fix, and prefer removing the source of non-determinism over adding a retry or a longer wait. Say explicitly if the right answer is to delete the test.

Test and failure output:

Making it yours

  • Paste your own material where the prompt asks for it. Everything above that line is instruction, not content.
  • Delete any rule that does not apply to you. A shorter prompt that fits beats a thorough one that does not.
  • If the answer comes back vague, add a line saying what you do not want. Constraints work better than encouragement.

Failing and flaky tests. Diagnosing a red run, stabilising a flake, and locking a fixed bug in with a regression test.

Related prompts

Keep this one

Phrasery saves prompts with a right-click and puts them back the same way. Add this to your own library in one click.

Add to your browser โ€” free