How to run thousands of browser tests in parallel
Run every browser test from a fresh copy of one prepared environment: app built, data seeded, browser ready. How to size a burst, and what it costs.
How do I run Playwright tests in parallel in isolated environments?#
Prepare one environment once, with the app installed, the test database seeded, the browser installed and a test user signed in on disk, and start every test run from a fresh copy of it. That way every run begins from the same known state, nothing one run leaves behind reaches the next, and no run spends its first minutes installing things. Size the burst from how many runs arrive together and how fast you need the answers, and pay per second, because short runs lose a large share of their cost to rounding when billed by the minute.
Why reused environments leak state between runs#
A shared runner or a reused container is cheap to set up and hard to keep clean. The browser is the part people think about, and it is the part that is already handled. Playwright's docs say tests run in what they call "isolated clean-slate environments called browser contexts," so "each test has its own local storage, session storage, cookies etc."
That isolation stops at the browser. Everything the app keeps outside the browser carries over.
The test database is the usual culprit. One run creates an order, another expects an empty cart, and the second fails on Tuesdays when the first ran before it. A migration that a crashed run left half applied breaks every run after it until someone notices. Server-side sessions outlive the browser context that created them. Files pile up on disk: uploads, downloads, screenshots, a cache directory that grows until it fills. A background process from the last run still holds port 3000, so the next app fails to start and the test reports a blank page.
Playwright's own authentication guide draws the same line. Reusing a saved signed-in state is "the recommended approach for tests without server-side state." For tests that change state on the server, "we will need multiple testing accounts, one per each parallel worker."
For an AI QA product the leak is worse, because an agent explores. It clicks things no scripted test would, fills forms with odd values and leaves the app in states nobody planned for. A fresh environment per run means every verdict is about this run alone.
Cleanup scripts help until they miss something. A fresh environment per run makes cleanup unnecessary.
Prepare once, start every run from a copy#
The pattern has two halves. Build a prepared environment once per version of the app. Start every run from a copy of it, and throw the copy away when the run ends.
What goes into the prepared environment#
Put everything into it that does not change from one run to the next:
- the app at a pinned commit, built, with its dependencies installed;
- the test database with its migrations applied and the seed data your tests expect;
- the browser and test framework your team already uses, for example Playwright with Chromium, with their system libraries;
- a test user's signed-in state saved to disk, such as a Playwright storage state file, so no run spends time on the login page.
Use a test account for that last item, never a real one. The Playwright docs warn that the state file "may contain sensitive cookies and headers that could be used to impersonate you or your test account." Real credentials, such as an API key the app calls out to, belong in a secret store that is given to each run at start and never written into the prepared environment.
Check it before anything runs in it#
A prepared environment that is broken breaks every run started from it, all at once. So build it with a check that has to pass: the app answers its health route, the database has its seed rows, and the browser launches and loads one page. If the check fails, nothing is stored and no run ever starts from it.
Start the app before the copy is made#
The app and its database should already be running in every copy, so the first thing a run does is open the browser. A copy that has to start a server, wait for it and run migrations is repeating work, and that repeated work is also where most setup failures happen.
Give each run its own slice#
When runs share an external service, such as a payments sandbox or an email inbox, give each copy its own test user or its own prefix. An index per copy, from 0 to N minus 1, is enough to pick one.
Rebuild when the app changes#
Make a new prepared environment for each commit you test, and record which one each run used. That way a result always points at an exact app version, with an exact database and browser version beside it.
Sizing a burst#
QA traffic comes in bursts. A deploy lands, a nightly suite starts, a customer clicks "run all", and hundreds of runs arrive in the same minute. The number of environments you need at once is simple arithmetic: runs in the burst, times the length of one run, divided by the time you are willing to wait for all of them.
Take an example. Say a burst brings 600 runs of about 3 minutes each, and the customer should have every result within 6 minutes. That is 600 × 3 / 6 = 300 environments at once, in two waves. Want every result in one wave of about 3 minutes? You need 600 at once.
Three things decide whether that works in practice. The first is your concurrency limit, and what happens past it: a clear refusal you can queue on is far better than runs that hang. The second is how start time holds up when hundreds start together, because a start that is fast alone and slow at width stretches every wave. The third is cost before the burst runs: you want to know the most a burst can cost before you start it.
Start time#
With a prepared environment, start time is the time to a fresh copy that is ready for its first command. Without one, every run also pays to install the browser and the app's dependencies, prepare the database and start the app. Those minutes repeat in every run, and in a burst they repeat hundreds of times at once against the same package mirrors.
Measure start at the width you will run, not one at a time. A start that takes a second alone and a minute at the back of a 500-wide queue turns a 3-minute run into a 4-minute one for the last few hundred.
What short runs cost when billed per second#
Short runs are where billing granularity matters most. Take a run that lasts 2 minutes 10 seconds. Billed per minute with rounding up, you pay for 3 minutes, about 38% more than the run used. At 3 minutes or less per run, that rounding is a large share of the bill.
Here is the arithmetic at the list rates on the Promigence pricing page, $0.0504 per vCPU-hour and $0.0162 per GiB-hour, billed per second. The workload is an example: 10,000 runs a week of about 3 minutes each.
| Size | Per hour | One 3-minute run | 10,000 runs a week |
|---|---|---|---|
| Small, 2 vCPU and 4 GiB | $0.1656 | $0.0083 | $82.80 |
| Medium, 4 vCPU and 16 GiB | $0.4608 | $0.0230 | $230.40 |
| Large, 8 vCPU and 32 GiB | $0.9216 | $0.0461 | $460.80 |
A browser, an app and a database in one environment usually want the medium size. Test your own suite on two sizes and compare; a larger size that finishes sooner costs less than it looks.
Compare that with keeping machines on for the peak. Those 10,000 runs are 500 environment-hours of work a week. Keeping 500 environments on all week, so a 500-wide burst never waits, is 84,000 environment-hours: 168 times the work. Per-second billing on environments that exist only while a run does removes that gap.
How Promigence fits this pattern#
Promigence is a sandbox platform for AI agents. Each sandbox is a full Linux environment, so your team installs the browser and test framework it already uses when it builds its snapshot. The snapshot and fork guide walks through the pattern above.
You build a snapshot from an image or a Dockerfile, with setup steps and a verify command, and it is stored only if the verify command exits 0. The build is billed per second while it runs, so a small build costs at most $0.17. A start command runs at build time and is already running in every sandbox made from the snapshot, which is how the app and its database are up before a run begins. The fresh target guide shows that with an app built from its Dockerfile.
Copies start with the snapshot's files, and what one run writes is its own. No sandbox can see, reach or address another, yours or anyone else's. Every sandbox in a run gets its own index, from 0 to N minus 1, to pick its test user. A snapshot is named by a hash of its contents and kept until you delete it. Secrets are never written into a snapshot you build, and a snapshot of a sandbox that was given a secret is refused unless you force it.
On start time, a Promigence sandbox is ready for its first command in 207 ms at p50, end to end through the CLI. Two hundred requested at once were all served at a 177 ms median with no retries. Start 100 runs at once and even the slowest 5% finish in under a second (0.94 s).
On sizing, a new account runs 20 sandboxes at once, each for up to an hour. To raise a limit, email support@promigence.ai. A request over a limit is refused before anything starts, with a code that names the limit, and the limits page lists them all. promigence run quote prices a run as if every sandbox ran for its whole timeout, and a run quoted over its cap is refused before it starts.
When a person needs to see the app under test from their own browser, promigence port expose publishes a port as a preview URL. Anyone with the URL can reach it, so take it down with promigence port revoke as soon as nobody needs it; it also ends with the sandbox.
FAQ#
How do I run Playwright tests in parallel in isolated environments?#
Prepare one environment with the app, its test data and the browser already installed, then start a fresh copy of it for each run or each shard. Browser contexts already isolate each test's browser state; a copy per run isolates the database, the files on disk and the running processes too.
Why do my tests pass alone but fail when run in parallel?#
Usually because the runs share something outside the browser: a database, a test account, files on disk or a port. One run changes it and another expects the old value. Give every run its own environment, or at least its own test user and its own data.
How do I reset the database between end-to-end test runs?#
The cleanest reset is to never reuse it. Seed the database once in a prepared environment and start each run from a fresh copy, so every run sees the same rows. Truncate scripts and transactions that roll back work too, until a run crashes halfway or the app writes outside the transaction.
How many browser tests can I run at once?#
Work it out from your burst: runs that arrive together, times minutes per run, divided by the minutes you can wait. Next, check the provider's concurrency limit and what happens past it. A new Promigence account runs 20 sandboxes at once, and support raises the limit on request.
How much does it cost to run a browser test in a cloud sandbox?#
At list rates billed per second, a 3-minute run on a 4 vCPU, 16 GiB sandbox costs about $0.023. In this example, 10,000 such runs a week come to $230.40. Per-minute billing with rounding up adds to every run that does not end on the minute.
Try Promigence#
Build your app, its seeded database and your browser into one verified snapshot, then start every run from a clean copy. Request access for free credit to start, and follow the quickstart.
Sources#
| Source | What it supports | Read |
|---|---|---|
| Playwright: Browser contexts | clean-slate browser contexts; per-test cookies and storage | 24 Nov 2026 |
| Playwright: Authentication | saved signed-in state for tests without server-side state; one account per worker; the warning about the state file | 24 Nov 2026 |
| Promigence: Quickstart | verified snapshots and what a build costs; the quote and the cap | 24 Nov 2026 |
| Promigence: Limits and notices | 20 sandboxes at once for a new account, raising a limit | 24 Nov 2026 |
| Promigence pricing | per-second rates by size | 24 Nov 2026 |
| Promigence for agent builders | 207 ms end to end through the CLI; 200 at once, all served, at a 177 ms median; 100 at once, the slowest 5% in 0.94 s | 28 Nov 2026 |