How do I fix flaky Playwright tests?
First confirm the test is flaky: it fails, then passes with no code change. Then remove the cause, which is usually a fixed sleep, a brittle locator, shared data or a race with the network. Retries only measure the problem. In Nexus StudioQA a failure that a retry passes reads FLAKY, so it stays visible until you fix it.
Last updated:
By the Nexus StudioQA team, Verdict System LLC. November 25, 2026.
How do I know it is flaky and not a real bug?
A flaky test passes and fails on the same code. A real bug fails every time. Nexus StudioQA records every retry: a failure that a retry passes is FLAKY, and a run that fails on its last attempt after an earlier retry is BREACHED_FLAKY, which says the failure itself is inconsistent. The real bug or flaky test guide walks through the decision.
What usually causes flaky Playwright tests, and what fixes each?
| Cause | Fix |
|---|---|
A fixed sleep such as waitForTimeout | Delete it and assert on the result. await expect(locator).toBeVisible() retries until it holds or times out. |
| A brittle locator: a long CSS chain, an index or XPath | Use a role, a label, a text or a test id. Locator health lists the weak locators of the open test, and Repair · line N proposes stronger ones. |
| Data shared between tests | Let each test create its own data and never depend on the order. Playwright gives each test a fresh browser context. |
| A race with the network | Wait for the response the page depends on, registered before the action that triggers it, or assert on what the user sees. |
| A forced click that hides a covered element | Remove force: true and fix the overlay. The Vet flags forced clicks. |
| The environment: a slow host, a bot challenge, a dead browser | This is not a flaky test. TIMEOUT, BLOCKED, UNREACHABLE and CRASHED name it, so you do not edit a good test. |
Should I just add retries?
Use them to measure, not to fix. Playwright's retries setting reruns a failed test, and trace: 'on-first-retry' keeps a trace of the first retry so you can see why it failed. A retry that passes still hides the instability from a plain pass or fail. Nexus StudioQA does not hide it: the run reads FLAKY, and a retry never hides a real defect, which stays BREACHED.
How do I see which tests flake most?
History keeps every verdict, so the tests that read FLAKY repeatedly stand out. The flakiness predictor scores each test and browser from your own History and says how sure it is, and a single run reads as low confidence. To put a price on it, the flaky test cost calculator turns hours lost into money.
Common questions
What is the most common cause of a flaky Playwright test?
The most common cause is timing: a fixed sleep, or a locator that matches before the page is ready. Replace waitForTimeout with a web-first assertion such as expect(locator).toBeVisible(), which retries until the visible result appears or the timeout ends. Shared test data and order-dependent tests come next.
Do retries fix flaky tests?
No. Retries rerun a failed test, so a flaky test turns green without anything being fixed, and the instability disappears from a plain pass or fail report. Keep retries to measure how often a test flips, record every retry, and fix the cause: timing, shared data, test order or an unstable application.
What does the FLAKY verdict mean?
FLAKY is the Nexus StudioQA verdict for a test that failed and then passed on a retry with nothing repaired. It means unexplained instability in the test or the application, not a fix. The retry stays on the record, so a flaky test never becomes a silent pass, and History shows how often it flips.
How do I tell a flaky test from an environment problem?
Look at why the run failed, not only that it failed. In Nexus StudioQA, TIMEOUT, BLOCKED, UNREACHABLE and CRASHED point at the environment: a slow server, a 403 or 429, a DNS failure or a crashed browser. FLAKY and BREACHED_FLAKY point at the test or the application itself.
The free trial runs the same tests with verdicts and evidence, and the getting started guide lists the requirements.