I turned on Playwright’s isolated retries and my suite went green five runs in a row. Every one of those runs also had at least three flaky tests. The setting didn’t fix anything. It moved the retries somewhere the flake couldn’t reach them.
retryStrategy: 'isolated' arrived in Playwright 1.62. Two releases later there are better tools for the job: test locks in 1.63 and --shuffle in 1.64. I built a small suite with the two classic flakes, shared state and hidden test order, and ran it on 1.64.1. Everything below is as of 1.64.1. Releases have been landing every four to five weeks, so 1.65 may be out by the time you read this.
A suite that fights over one setting
Six tests save a theme to one shared account setting, wait for a fake 400 ms round trip, then check that they read back their own value. Each one is correct on its own. Twelve unrelated tests run next to them, and every third one resets the setting, the way a “reset preferences” test would.
for (const theme of ["dark", "light", "sepia", "contrast", "solar", "mono"]) { test(`saves theme ${theme}`, async ({ page }) => { writeTheme(theme); await page.setContent(`<button>Save</button>`); await page.waitForTimeout(400); // "server round trip" expect(readTheme()).toBe(theme); });}The config is the usual CI shape: fullyParallel, four workers, two retries. I ran it five times with each retry strategy.
| run | immediate |
isolated |
|---|---|---|
| 1 | 3 flaky, 15 passed | 3 flaky, 15 passed |
| 2 | 3 flaky, 15 passed | 3 flaky, 15 passed |
| 3 | 1 failed, 2 flaky, 15 passed | 3 flaky, 15 passed |
| 4 | 3 flaky, 15 passed | 5 flaky, 13 passed |
| 5 | 2 failed, 1 flaky, 15 passed | 3 flaky, 15 passed |
With the default, immediate, the build went red twice. With isolated, it never did. The flaky count never went down either.
Isolated retries move the retry, not the bug
immediate retries a failed test right away, in the same crowded pool. If the test failed because a neighbour was writing the same setting, the retry often lands next to another writer and fails again. isolated holds every retry until the rest of the run is done, then runs them one by one in a single worker. Alone, the test passes.
export default defineConfig({ fullyParallel: true, workers: 4, retries: 2, retryStrategy: "isolated", // 1.62+, default "immediate"});Flip between the three settings to see where each retry runs. This is a hand-drawn schedule shaped like run 3, not a trace of it:
1 failed, 2 flaky: red. Retries go straight back into the crowd. The dark retry lands next to sepia, they overwrite each other, and dark runs out of retries.
0 failed, 2 flaky: green. Retries wait until everything else is done, then run one at a time. They pass. The collision in the first column still happened.
0 failed, 0 flaky: green. Every test that writes the setting holds the same lock, so no two of them share a column. Nothing to retry.
writes the shared setting unrelated test retry end of the main run
So “flaky under isolation” is a diagnosis, not a fix. A test that fails in the crowd and passes alone is fighting with something running next to it. The type docs say what it costs, too: retries run “at the expense of the total run time”, serially, at the end.
A test lock fixes the collision
Playwright 1.63 added locks. Tests that share a lock name never run at the same time, across files, workers and projects. It’s one option on the test:
test(`saves theme ${theme}`, { lock: "account-settings" }, async ({ page }) => { // same body as before});test.describe takes the same lock option, and 1.64 added test.describe.configure({ lock }) to lock a whole file. With the lock and --retries=0, the suite went 18 passed, 0 flaky in 8 of 8 runs:
[17/18] tests/settings.spec.ts:7:7 › saves theme solar[18/18] tests/settings.spec.ts:7:7 › saves theme mono 18 passed--shuffle finds the tests that need an order
The second flake hides better. “add to cart” writes a cart file, and “checkout” assumes it exists. In the order they’re written, both pass every time, so nobody notices.
test("add to cart", async () => { fs.writeFileSync(DB, '["sock"]');});test("checkout", async () => { const cart = fs.existsSync(DB) ? JSON.parse(fs.readFileSync(DB, "utf8")) : []; expect(cart).toContain("sock");});1.64 added --shuffle, which runs test files, and tests in parallel mode, in a random order. On one worker with retries off, “checkout” failed in 4 of 6 shuffled runs. The header prints the seed:
Running 2 tests using 1 worker, shuffle seed 245155859
✘ 1 tests/order.spec.ts:7:5 › checkout ✓ 2 tests/order.spec.ts:6:5 › add to cart--shuffle 245155859 reproduced it 2 of 2 times. A failure that only shows up under one order is a test leaning on state another test left behind. Make “checkout” create its own cart.
Quarantine what you can’t fix today
Some flakes take longer than an afternoon. Reporter.preprocess(), new in 1.62, runs after the config resolves and before any test starts. It gets a TestRun with exclude, fail, fixme, skip and skipSharding, so a reporter can sideline known-flaky tests by title:
import type { Reporter, FullConfig, Suite, TestRun,} from "@playwright/test/reporter";import fs from "node:fs";
const quarantined: string[] = JSON.parse( fs.readFileSync(__dirname + "/quarantine.json", "utf8"),);
export default class QuarantineReporter implements Reporter { async preprocess({ suite, testRun, }: { config: FullConfig; suite: Suite; testRun: TestRun; }) { for (const t of suite.allTests()) if (quarantined.includes(t.title)) testRun.fixme(t, "quarantined: see flake tracker"); }}It sees the full suite before sharding, and it can’t change setup or teardown projects. With ["checkout"] in quarantine.json and the failing seed, “checkout” was skipped and the build went green. That’s the “quarantine it or fix it” rule from the testing strategy post, written down where the runner can enforce it.
Same seed, same config, three ways of picking the reporter:
| command | result |
|---|---|
npx playwright test |
1 skipped, 1 passed |
npx playwright test --reporter=dot |
1 failed, 1 passed |
npx playwright test --add-reporter=dot |
1 skipped, 1 passed |
No warning on the second one. If a CI step passes --reporter, switch it to --add-reporter.
Cancel hung work with a signal
1.62 also lets you pass an AbortSignal to most actions and web-first assertions. I aborted a toBeVisible() after 500 ms. It rejected after 506 ms with expect(locator).toBeVisible() failed, instead of waiting out the 5 s default:
const controller = new AbortController();setTimeout(() => controller.abort(), 500);await expect(page.getByText("paid")).toBeVisible({ signal: controller.signal });Two details. The signal doesn’t switch the timeout off, so pass timeout: 0 if you want only the signal. And I aborted with new Error('payment gateway cancelled'), and that reason didn’t show up in the first line of the error, so don’t count on it.
locator.waitForFunction(), also new in 1.62, waits on a condition about one element. This one resolved once the bar filled:
await page.locator("progress").waitForFunction((el) => el.value >= 100);WebP artifacts: measure first
1.62 added WebP screenshots, and 1.64 lets you make every unnamed screenshot WebP from the config:
export default defineConfig({ expect: { toHaveScreenshot: { type: "webp" } },});The pitch is smaller CI artifacts. For goldens, that depends on the page. toHaveScreenshot goldens are lossless, and on a flat page Playwright’s WebP was 8 times bigger than the PNG. I took these at 1280x720:
| subject | PNG | WebP lossless | WebP quality: 50 |
|---|---|---|---|
flat page, one <h1> |
8,162 B | 67,146 B | n/a |
| playwright.dev | 318,715 B | 258,980 B | 28,650 B |
On a busy real page the lossless WebP was 19% smaller. Lossy WebP is about 11 times smaller, but only page.screenshot({ quality }) takes it, so it’s for debug screenshots, not goldens. For reference, cwebp -lossless -z 9 turned the same two PNGs into 1,474 B and 129,134 B, so Playwright seems to use a fast, low-effort encoder. Try it on your own suite before you flip the config.
If CI creates missing goldens, 1.64 changed that too: --update-snapshots=missing now passes when it only writes missing snapshots. My run that wrote a new WebP golden reported 1 passed.
Upgrading can add flakes too
Pin 1.64.1, not 1.64.0. The patch fixes #43242, where Chromium 155+ aborted preflighted cross-origin redirects whenever any route was registered, plus a flaky Electron first window.
Two other 1.64 changes can turn a stable test red after the upgrade. Device descriptors now forward screen, and elements inside hidden iframes count as hidden. Run the suite a few times on the new version before you blame the tests.
1.62 also bundled npx playwright mcp and npx playwright cli for agent-driven debugging. I didn’t use either for any of this.
What I’d set up
If you followed the SvelteKit series, you already have a playwright.config.ts. In this order:
- Pin
@playwright/testto 1.64.1. - Set
retryStrategy: 'isolated'and read the flaky list as “fights with something in parallel”. - Put a
lockon every test that touches the shared thing, then drop retries for those tests and watch it stay green. - Run
--shuffleon a schedule, and save the seed from any red run. - Quarantine the rest in
preprocess(), and use--add-reportereverywhere CI adds a reporter.
Isolated retries tell you which tests are fighting. A lock stops the fight.

