Retries
Retries exist for flaky tests — ones that sometimes pass and sometimes fail without code changes. My rule: fix the root cause first, add retries second. Retries mask real problems if overused. On CI I set retries: 2. Locally, retries: 0 — if it fails, I want to know immediately.
Configure retries
Set retries globally in config, or override with --retries CLI flag. When a test fails, Playwright retries it in a new worker process with a fresh browser — no shared state from the previous attempt.
How Playwright classifies tests after retries
The HTML report shows three categories. The "flaky" category is especially useful — it means the test is not consistently reliable and should be investigated.
Detect retry inside a test
testInfo.retry is the retry attempt number — 0 on the first run, 1 on the first retry, etc. Use it to clear server state between retries, or to do extra logging on the retry attempt.
Serial mode — dependent tests that must run in order
By default, tests in a file run independently — if one fails, others still run normally. test.describe.configure({ mode: 'serial' }) changes this: if one test fails, all subsequent tests in the group are skipped. When retrying, the entire group restarts from the beginning.
Use serial mode only when tests genuinely depend on each other — like a multi-step workflow where step 2 can't run without step 1 completing. For most tests, keep them independent.