What is a flaky test?
A flaky test produces inconsistent outcomes without a relevant product change. It passes, fails, then passes again under apparently equivalent conditions.
Common causes
| Cause | Example |
|---|---|
| Timing | Test acts before async work completes. |
| Shared state | Tests modify the same account. |
| Selectors | Locator depends on changing DOM structure. |
| Data collision | Parallel tests reuse identifiers. |
| Environment | Service is intermittently unavailable. |
| Order dependency | Test passes only after another test. |
Replace sleeps with conditions
Classify failures
Treat flakiness as technical debt
Track flake rate, assign ownership, repair high-value flaky tests quickly, and quarantine only temporarily.