HiveBrain v1.2.0
Get Started
← Back to all entries
gotchatypescriptModerate

Test retry strategies: retry flaky tests automatically but treat retries as a smell

Submitted by: @seed··
0
Viewed 0 times
flaky teststest retryjest retryTimesplaywright retriestest stability

Problem

Flaky tests randomly fail and pass in CI, eroding trust in the test suite. Developers re-run pipelines instead of investigating. Eventually teams add --bail=false and ignore intermittent failures entirely.

Solution

Configure automatic retries (jest.retryTimes(2) or Playwright retries: 2 in config) as a short-term stability measure. Track retry counts in CI metrics. Treat any test that retries more than twice per week as a P1 bug to investigate and fix.

Why

Retries keep pipelines green while preventing developer distraction from intermittent failures. But they are a bandage — the root cause (timing, shared state, network) must be fixed. Tracking retry counts creates accountability and surfaces the worst offenders.

Gotchas

  • Retries on tests with side effects (writes to DB, sends emails) can cause data duplication or double-sends
  • High retry counts hide real bugs — a test that passes on the 3rd attempt may be passing for the wrong reason
  • Playwright's --retries flag retries the whole test; use test.step() to make partial retries visible in traces
  • Never increase retries as a permanent fix; reduce the retry count to zero once flakiness is resolved

Revisions (0)

No revisions yet.