Environment failures vs real bugs in browser tests
Many failed browser test runs never reached the app. How AI QA teams tell environment failures from real bugs, which retries are safe and what to record.
Why do my Playwright tests fail randomly in CI?#
Many failed browser test runs never tested the app at all. The environment did not start, the browser never launched, the connection to the run dropped, a process ran out of memory, or a package mirror timed out during setup. A QA product has to label those as environment failures, run them again on a clean copy and keep them out of the verdict it sends the customer. A red result that turns out to be the platform's fault costs far more in trust than it costs in compute.
What a browser test run is made of#
A run that an AI QA agent or a browser agent performs has more moving parts than the test itself. Something has to start an isolated environment. Setup then installs or loads the app under test, seeds its database and installs the browser with its system libraries. The browser has to launch. Your agent or test driver connects to it, works through the app, takes screenshots and checks what it sees. Only at the very end does the run produce the thing your customer pays for: a verdict.
Each layer can fail on its own. Only the last one says anything about the app.
The most common failures sit below the test. The environment never starts, or starts but never becomes ready for its first command. Setup breaks: a package mirror or container registry times out, the database migration hits a lock, a download returns half a file.
Then the browser has its own ways to fail. The launch times out, or Chromium crashes because the environment is short of shared memory; the Docker guide in Playwright's docs warns that without the right setting, "Chromium can run out of memory and crash." The connection between your driver and the environment drops halfway through, so the run stops mid-step with no assertion failing. Or memory runs out under load, since the browser, the app and its database share one environment and a long session with many tabs pushes one of them over the edge.
None of these is a bug in the customer's checkout page. All of them show up as a red run unless something tells them apart.
Why a false red hurts a QA product more than anyone#
For an internal test suite, a flaky run is an annoyance. Someone reruns the job and moves on. For a company that sells AI QA, the run result is the product. The customer is paying for one answer: does my app work?
Send them a red result with a screenshot of a blank page, and an engineer on their side drops what they are doing to look for a bug. If the cause was your environment, you spent an hour of their time and some of their belief in your next report. A run result is only as useful as the environment under it, so the platform should report its own failures separately and never count them against the app.
There is a quieter cost on the other side. A run that never reached the app must not count as a pass either. If a setup failure skips the test steps and the harness reads "no assertion failed" as green, you have shipped a false green. That one does not cost an hour. It lets a real bug through.
Browser-agent eval teams and agent-simulation platforms have the same problem in a different shape. A sandbox that broke halfway through gets scored as the agent failing the task, and the score moves for a reason that has nothing to do with the agent. We covered that side in our guide to sandboxes for agent evals.
How to tell an environment failure from an app failure#
No single signal settles it. Four together get you most of the way.
Where in the run it stopped#
Record the phase each run reached: environment ready, setup done, app healthy, browser launched, first step taken, verdict written. A run that stopped before the app answered its health check is not evidence about the app. Phase is the cheapest signal and the strongest.
What the error says#
A launch timeout, a closed browser before the first navigation, a refused connection to the driver or an exit by signal all point at the environment. When an assertion fails on a specific element and the app's own error is in its logs, that points at the app. The gray zone is a timeout inside a step: the page took too long. That is either a slow app or a starved environment, and the next two signals decide it.
Does it fail again on a clean copy#
Run the same test against the same build of the app, in a fresh environment that starts from the same prepared state. A real bug fails the same way again. Most environment failures do not. Do this on a fresh copy, never in the environment that just failed: a half-finished migration or a full disk from the first attempt will poison the second.
How many runs failed together#
When forty runs fail in the same minute, across different customers and different tests, the app is not the common factor. Group failures by time and by error type before you send anything to a customer.
| Failure | What you see | Environment or app | What to do |
|---|---|---|---|
| Environment never ready | Error before any setup output | Environment | Start it again; send no verdict |
| Setup timed out | Mirror or registry timeout, partial download | Environment, your setup | Retry once; move installs into a prepared snapshot |
| Browser did not launch | Launch timeout, browser closed before first page | Environment | Retry on a fresh copy; if it repeats, fix the image |
| Connection dropped | Run stops mid-step, no assertion failed | Environment | Rerun the whole test from a clean start |
| Out of memory | Browser or app killed by signal | Your size choice, or the platform | Over the size you picked: go larger. Within it: the platform's failure |
| Step timed out | Element never appeared | Either | Rerun on a clean copy and compare |
| Assertion failed the same way twice | Wrong text, wrong state, app error in logs | App | Report it, with both runs as evidence |
Retries that are safe, and retries that hide bugs#
Retrying is the obvious fix, and it is easy to get wrong. Playwright's test runner names the problem in its own categories: a test is "flaky" when it "failed on the first run, but passed when retried." Retries keep the pipeline green. They also make a real intermittent bug look like noise.
A retry is safe in three situations. The run failed before the app received any action. The run failed with an environment signal such as a launch failure or a dropped connection. Or the retry starts from a clean copy of the same prepared state, so the second attempt cannot inherit the first one's mess. Playwright does the browser half of this already: after a failure it will "discard the entire worker process along with the browser and will start a new one." Do the same with the whole environment.
A retry is not safe when an assertion failed inside the app and you retry until it passes. Report that run as flaky, with both attempts attached. One failure in five is still a bug.
Set a budget. One automatic retry for environment failures is reasonable. A second failure of the same kind on a fresh copy is something to fix in your setup, and it belongs on your dashboard rather than the customer's.
What to record for every run#
You cannot classify what you did not record. Keep these with every run, pass or fail:
- the exact environment it started from, by an identifier that cannot drift, plus the app's commit and the test or prompt version;
- the phase it reached, its exit status and a failure class: environment, setup, app or test;
- the browser and driver versions, with the trace or screenshots from the last step;
- how many attempts it took, and why each retry happened.
With that in place, two questions get one-line answers. What share of this week's red runs were real? Did the environment change between Tuesday's run and Wednesday's?
What Promigence gives a QA team#
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, for example Playwright with Chromium, when it builds its snapshot. These are the parts that answer the problems above.
Snapshots are built with a verify command, and a snapshot that fails its own test is never stored. Point the verify command at your app's health check and your browser launch, and an image that cannot start the browser fails at build time instead of inside a customer's run. Memory and disk ceilings are validated when the snapshot is built too. Snapshots are named by a hash of their contents, so "the same environment" means the same files.
A sandbox that is not ready is never handed over, and a busy environment is never marked unhealthy, even with every vCPU busy. A sandbox that fails before hand-over is retried once automatically when the run has a command, and it is not billed. After hand-over, when Promigence's side shows a failure was its own, the work since the last snapshot (or since the start), up to 24 hours, is credited back.
Every run ends with a validity report that splits environment failures from task failures, and the CLI exits 3 when the environment failed and 4 when the task did. promigence run replay puts only the environment failures through again, in new sandboxes under the run's cap. promigence run open reopens a failed sandbox at the moment it failed, so you can look at the browser and the app as they were. The errors page lists every failure with whose it was and whether it was billed.
You can give a sandbox full outbound access, none, or an outbound allow-list, and refused connections are recorded. Secrets are given only to the commands that name them and removed from logs and outputs. A run is quoted before it starts and held to a hard spend cap. Billing is per second at $0.0504 per vCPU-hour and $0.0162 per GiB-hour.
FAQ#
Why do my Playwright tests fail randomly in CI?#
Most random failures come from the environment or from timing. Short shared memory can crash Chromium, too many parallel workers starve the machine, and state left by an earlier run changes what the next one sees. The CI guide in Playwright's docs recommends one worker in CI, for stability. Starting every run from a clean, prepared environment removes the leftover-state cause entirely.
How can an AI QA agent tell a real bug from a flaky test environment?#
Check four things: the phase the run reached, the kind of error, whether it fails again on a clean copy of the same environment, and whether many unrelated runs failed at the same moment. A failure before the app answered is the environment's. If an assertion fails the same way twice on clean copies, it is a real bug.
Should I retry failed browser tests automatically?#
Retry environment failures once, on a fresh environment, and never count the retry as a clean pass for an app failure. If an assertion fails and then passes, report the test as flaky with both attempts attached, because an intermittent failure can be a real bug.
Why does Chromium crash when running Playwright in a container?#
The usual cause is shared memory. Playwright's Docker guide recommends --ipc=host with Chromium, because without it "Chromium can run out of memory and crash." Running many browsers in one container also adds memory pressure, so size the environment for the browser, the app and its database together.
Who pays when a test environment fails?#
That depends on the provider, so ask before you buy. On Promigence, an environment failure before the sandbox reaches you is not billed, and the validity report keeps it apart from task failures so it never counts against the result.
Try Promigence#
Build your app, its test data and your browser into one verified snapshot, then run every test from a clean copy and read which failures were real. Request access for free credit to start, and follow the quickstart. The snapshot and fork guide shows the pattern step by step.
Sources#
| Source | What it supports | Read |
|---|---|---|
| Playwright: Docker | --ipc=host with Chromium; "Chromium can run out of memory and crash" | 24 Nov 2026 |
| Playwright: Retries | the categories passed, flaky and failed; a new worker and browser after a failure | 24 Nov 2026 |
| Playwright: Continuous Integration | one worker recommended in CI | 24 Nov 2026 |
| Promigence: Errors and exit codes | environment versus task failures, retry before hand-over, what is billed or credited | 24 Nov 2026 |
| Promigence: Quickstart | verified snapshots, the validity report | 24 Nov 2026 |
| Promigence FAQ | replay, network rules, secrets, per-second rates | 24 Nov 2026 |