All topics / Flaky Tests

Flaky Tests

Why a test passes and fails with no code change, the usual culprits, and how to kill flakiness for good instead of hiding it behind retries.

  1. What a Flaky Test Actually Is A flaky test is nondeterministic: the same code yields different results because hidden inputs — time, order, randomness, the network — leak into a test that should be a pure function.
  2. The Usual Culprits A field guide to the five everyday sources of flakiness — timing and sleeps, async not awaited, test order and shared state, real externals, and leaked resources — and the fingerprint each one leaves.
  3. Diagnose, Fix, Quarantine The playbook for killing flakiness: rerun and isolate and seed to find the cause, control time/randomness/state/externals to fix it, and quarantine — never silently ignore — when you can't fix it today.