how to retry flaky tests without hiding real failures
Configures test retries that catch flakes without masking regressions. Use when setting retry policy. Not for quarantine decisions.
TL;DR
Retries are a diagnostic tool, not a fix. Retry failures a small fixed number of times, track what needed retries, and treat a test that always needs its retries as broken.
Error
(Not an error; a policy. The failure it prevents: retries hiding a growing flake problem.)Steps
- Set retries low: 1-2 in CI, 0 locally. Expected: flakes get a second chance; developers feel the pain.
- Record which tests passed only on retry. Expected: the flaky set is visible.
- Alert when a test needs retries consistently (for example 3 days running). Expected: chronic flakes get fixed.
- Never raise retries to make a red suite green. Expected: the retry count is a policy, not a dial.
- Pair retries with quarantine: chronic retry-users get quarantined. Expected: the suite stays honest.
When to use
- Configuring retries for the first time.
- Retries are masking a growing problem.
When not to use
- Deciding whether a specific test is flaky (detect first).
- Load or soak testing (different kind of repetition).
Tool compatibility
- Playwright
retries, Cypressretries, pytest-rerunfailures, Jest--retry.
Variant phrasings
Test retry best practices
The policy question; low retries plus tracking.
Should I retry flaky tests
Yes, but as a diagnostic with tracking, not a fix.
Why it happens
Retries convert some flakes into passes, which is useful, but unmonitored retries convert signal into silence.
Edge cases
- Retries multiply CI time; budget them.
- Some frameworks retry the whole file, not the test; know which.
- Retry data is the input to quarantine decisions.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstxy0Ee1sOk6usstfieO05Q
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.