Test retry

Automatically rerun a failed test once or twice before calling the build red, usually to contain a known intermittent failure.

rerun a failed test automaticallytry the test again before failing CIit passed on the second tryrerun failures twicegive the flaky test another chancetest retyautomatic rerun in Playwrightjust hit rerun until the build goes green

What it is

A test retry automatically runs a failed test again before the runner declares the build broken. It is useful at boundaries where a small amount of nondeterminism is real and temporary, such as a browser test waiting on a remote sandbox. Playwright can retry a failed test in a fresh worker and reports one that fails first but passes later as flaky.

Use a small, visible retry budget as containment while you investigate, not as the default cure for every red test. Capture the first failure's trace, logs, and screenshot, because that attempt contains the evidence you need. Keep unit and integration tests deterministic enough that they normally need no retries at all.

Gotcha: a retry can turn a real race condition into a green build. It also multiplies the slowest failures, so three attempts across a large browser suite can erase the time you saved elsewhere. Track retried tests separately, set an owner and deadline, and fix or quarantine the underlying flake.

Ask AI for it

Configure Playwright Test with retries: process.env.CI ? 2 : 0 and trace: 'on-first-retry'. Preserve the trace, screenshot, and console output from the first failed attempt, report tests that pass only after a retry as flaky, and make the CI summary list them separately. Do not retry unit tests, do not add fixed waits, and document an owner and removal date for every test that consumes the retry budget.

You might have meant

flaky testtest quarantineend to end testtest runner