I have a weird obsession with making stuff run faster, even when it seems practically impossible to do so, which was the case with Playwright.
I thought most of my tests were slow because my app or the way I designed my tests sucked, so I took every measure I could to improve my e2e suite’s speed. I saw a lot of improvements by simply “doing things right”, like using data-testid selectors, running tests in parallel, caching frontend builds, seeding data efficiently, etc.
Eventually I hit a wall, and I started wondering how much of that wall was Playwright’s fault. My first instinct, like any good vibecoder, was to ask Claude to rewrite the entire thing in Rust, to which it smartly replied, after running some benchmarks, that it would be pointless.
I didn’t know what to do, so I (and Claude) came up with a bunch of ideas for how to speed up tests, from preparing your next test run while the current one is running to ignoring CSS animations. I had GPT 6 Astra write down 120 potential ideas, and only a few of them actually worked out without compromising functionality. In total I had 2 agents running every day for almost an entire week. And this is the result:
Flashwright is a fork of Playwright 1.64.1 that keeps the API, the test runner and the npx playwright test command, and adds a bunch of performance tricks and some quality-of-life features. You swap the package and keep your tests.
The numbers
I benchmarked it against Playwright on Playwright’s own example suites and a bunch of other scenarios. Every number is the median of 15 runs of the complete test command, from launch to exit, on the same 6-CPU Linux machine with Chromium’s headless shell, and nothing in the test code changes:
| Scenario | Workers | Playwright | Flashwright | Speedup |
|---|---|---|---|---|
| TodoMVC example suite (24 tests) | 1 | 3617 ms | 968 ms | 3.74× |
| TodoMVC example suite | 4 | 1767 ms | 721 ms | 2.45× |
| SVGOMG example suite (6 tests) | 1 | 1687 ms | 523 ms | 3.23× |
| Shop app (sign-in setup, 40 ms API) | 1 | 6429 ms | 2950 ms | 2.18× |
| Admin page with 8,500 elements | 4 | 2639 ms | 1293 ms | 2.04× |
| A suite where every third test fails | 1 | 4266 ms | 1128 ms | 3.78× |
toHaveScreenshot() against a baseline |
1 | 2297 ms | 916 ms | 2.51× |
| A single test, the way an agent re-runs it | 1 | 577 ms | 187 ms | 3.09× |
It’s at least 2× faster in every scenario I measured, 2.83× on average, and the full matrix has 20 rows if you want all of them.
The smallest gains are on the suites where the app itself is slow. A server that takes 40 ms to answer still takes 40 ms, so the shop and admin apps sit at around 2×. If you subtract the time the app spends waiting on its own API, the overhead Flashwright adds on top is 2.9× to 4.8× lower than Playwright’s. More workers also shrink the ratio, because a lot of what Flashwright saves is per-test overhead that parallelism was already hiding.
I also ported the same 24 TodoMVC tests to eight other tools to see where everything lands. Same actions, same assertions, same CSS selectors, same Chromium 156, each tool with its own recommended waits:
Cypress can’t run spec files in parallel without Cypress Cloud, which is why its 4-worker bar doesn’t move. I wrote all the ports myself, so if you know a faster way to set one of them up, the ports are in the repo and I’d happily take the PR.
Where the time actually goes
The biggest single cost in a lot of suites isn’t Playwright’s code at all. It’s the browser compiling your app’s JavaScript again in every fresh renderer. Playwright gives each test a brand-new browser context, which is great for isolation, but it means every test pays for a cold start of your app.
So the trick that matters most is keeping one context per worker and giving each test a new tab in it, then resetting everything a test could have changed: options, permissions, cookies, every visited origin’s storage (local, session, IndexedDB, Cache Storage, service workers), caches, routes, init scripts, bindings, downloads and the clock. The previous test’s pages are stopped before anything gets cleared, so a late script can’t leak state into the next test. That reset is the part that really has to be right, and it’s what tests/page/recycle-isolation.spec.ts checks.
Everything else is about not waiting for nothing. Playwright re-checks actions and assertions on a 20 to 500 ms backoff, so even when the page is ready, you often wait a bit for the next poll. Multiply that by every action in every test and it adds up to more than you’d expect.
The tricks
These are on by default:
- Reuse browser contexts. Each worker keeps a context and gives each test a new tab, then resets storage, permissions, routes and the other state a test can change. Firefox and WebKit reuse the tab too.
isolation: 'strict'creates a new context per test. - React when the page changes. Actions and assertions re-check on page changes instead of waiting through a 20-500 ms backoff.
- Fail early when the page is idle. Assertions stop waiting when nothing can change the page before their timeout.
failFastWhenIdle: falserestores the full wait. - Skip animation-frame waits before input. Pointer actions don’t wait for elements to stop moving. Playwright’s hit-target check still verifies that the element receives the input.
waitForAnimations: truerestores the wait. - Start workers and browsers early. They start while the CLI reads the config, and spare workers, browsers and contexts are prepared for when they’re needed after a failure. Workers that don’t need a browser close it.
- Run the longest tests first. Previous test durations determine scheduling across workers, so less time goes to waiting for one worker to finish.
testOrder: 'file'restores Playwright’s order. - Cache compiled code and load less. V8 code caching reduces startup work, unused modules load lazily, and minified page scripts are compiled once by the browser.
playwright clicommands start in about 45 ms instead of 260. - Do less work per call. Stack traces are formatted lazily, and actions make fewer browser round trips.
- Use binary browser messages. Chromium’s DevTools connection uses CBOR instead of converting every message to JSON and back. That alone is up to 9% on short tests and 4% on TodoMVC with 4 workers.
- Make locators cheaper. Queries avoid repeated style, role and label calculations, and named role locators rule out irrelevant candidates before computing their accessible names. On the 8,500-element admin page, a named
getByRole()takes 14 ms instead of 41. - Encode screenshots faster. PNG encoding prioritises speed while keeping identical pixels. Files are 1.6-1.9× larger, but
toHaveScreenshot()baselines stay unchanged. - Compare screenshots faster. Pixel comparisons have fast paths, including returning immediately when nothing changed.
- Avoid unnecessary failure screenshots. With
screenshot: 'only-on-failure', eligible pages are held for up to 20 ms while the test outcome is determined, so passing tests don’t need a screenshot. On TodoMVC that took the run from 1484 to 1055 ms, basically the same as with screenshots off. - Keep browsers warm between runs. Outside CI, a background session keeps browsers and warmed renderers around for the next command, while each run still gets fresh runner and worker processes. A single TodoMVC test goes from 652 ms on Playwright to 72 ms.
FLASHWRIGHT_SESSION=0disables it. - Make watch mode react sooner. File changes trigger affected tests without first listing the entire suite, while workers, browsers and the test-loading process are prepared for the next run. A change gets reported in 255 ms instead of 1065.
- Return from MCP calls when the page settles. Adaptive settling replaces the fixed 500 ms wait.
The warm session and the MCP one are mostly for agents. When Claude edits something and re-runs a single test twenty times in a row, the difference between 0.6 s and 0.07 s per run is very noticeable.
There are also some optional ones, off by default because each one trades something away:
- Share processes between workers.
workersPerProcesslets workers share Node.js, loaded code and a browser while keeping separate contexts. It uses less memory, but workers also share process globals and failures. - Preload the next page.
preloadPagesloads the next test’s page while the current test runs, subject to worker-count limits. It needs care when tests change server state before navigation. On TodoMVC with 1 worker it’s another 1.26×. - Speed up animations.
instantAnimationsmakes CSS transitions, CSS animations and Web Animations run 1000× faster in Chromium. - Skip unnecessary resources.
blockResourcesstops selected resource types, such as images, fonts and media, from loading. - Require test-ID locators.
locatorPolicy: 'test-id'restricts element selection to test-ID locators and their combinations, which avoids the work of resolving roles, labels and text.
What didn’t work
Most of the 120 ideas didn’t make it. Some were slower once measured on whole runs, some broke tests, and some saved a millisecond that something else immediately spent again.
The biggest detour was patching Chromium. I had the agents build Chromium 156 from source, at parity with Chrome for Testing, and measure the candidates one by one. Shipping Flashwright’s injected script once per context instead of once per tab was worth about 1-2% after the CBOR change. Opening a new tab takes about 2 ms, but those 2 ms are 6 to 10 tiny steps hopping between the browser and the renderer, with no single step big enough to be worth patching. Even opening a spare tab during the previous test didn’t help: it just moved the same 2 ms into the next test’s navigation.
So no patch paid for the trouble of maintaining a Chromium fork, and Flashwright runs Playwright’s own browser builds. You don’t have to install or trust a custom browser to use it.
What’s different from Playwright
The API is compatible, but some defaults change what a test can observe, and I’d rather you know before you switch:
- Isolation. Contexts are reset and reused instead of created per test, and Firefox and WebKit also reuse the tab, history included. If you depend on a truly fresh context, set
isolation: 'strict'. - Moving elements. Pointer actions don’t wait for animations. If your app ignores input while something animates, set
waitForAnimations: true. - Assertion timeouts. Assertions can fail early on an idle page. If a test changes the page from a Node.js timer while an assertion waits, set
failFastWhenIdle: false. 8 of Playwright’s own page tests do exactly that. - Test order. With several workers, the longest tests start first.
- Background processes. Locally, the warm session keeps a browser around for up to 5 minutes after the command exits. It holds about 0.4 GB after a one-test run and around 1 GB after a 4-worker suite.
On compatibility, Flashwright passes 2616/2616 tests from Playwright’s own tests/page suite on Chromium, and the runner, library, MCP, Electron and extension suites match a pristine Playwright 1.64.1 on the same machine. The only two library differences are checks of internal bookkeeping that notice the recycled context. So for most suites it should be a drop-in replacement, but if yours does something unusual, the options above turn each behaviour back.
Trying it
Replace @playwright/test and keep everything else, imports and commands included:
npm i -D @playwright/test@npm:flashwright-test
npx playwright install chromium
npx playwright test
You need Node.js 22.18 or newer. It also runs TypeScript tests on Bun with bunx --bun playwright test, which stock Playwright can’t do. If you use the library without the test runner, playwright becomes flashwright the same way.
Benchmarks, the docs for every option, and the source are in the repo. It’s Apache-2.0 like Playwright, and if it breaks something in your suite, I’d really like to see the issue.