SoftwareTestPilot
Automation TestingPublished: 13 min read

Flaky Tests — 15 Causes and Proven Fixes (2026)

The 15 root causes of flaky tests in 2026 and the exact fix for each. Timing, isolation, data, network, browser, CI, and infra causes — with Playwright, Cypress, and Selenium code samples.

Avinash K
Founder & QA Engineer at SoftwareTestPilot
Share:XLinkedInWhatsApp
Flaky tests — 15 root causes and proven fixes 2026.
Flaky tests — 15 root causes and proven fixes 2026.

Last updated 2026-07-20 · 13 min read · By Avinash K

Flake rate is the single strongest predictor of whether a QA team ships on time. Above 5% flake, engineers stop trusting CI; above 10%, they stop reading it. Here are the 15 causes we see repeatedly across audits — and the proven fix for each.

Key takeaways

  • The 15 root causes grouped by category.
  • Playwright, Cypress, and Selenium fixes for each.
  • A weekly triage ritual that keeps flake below 2%.
  • The one metric to track (Flake Rate, not Pass Rate).

1. Timing (5 causes)

  1. Fixed sleeps — replace with auto-waiting locators.
  2. Race on networkpage.waitForResponse then assert.
  3. Animation not settled — disable animations in test config.
  4. Focus stolen by another tab — pin browser tab, disable notifications.
  5. System clock skew — freeze time with fake timers.

2. Isolation (3 causes)

  1. Shared test data — each test creates and cleans its own user.
  2. Global state — reset localStorage / cookies between tests.
  3. Parallel worker collision — namespace by workerIndex.

3. Network and data (3 causes)

  1. Flaky third-party — stub in tests, contract-test separately.
  2. DB seeded once, mutated by tests — seed per test.
  3. External auth provider throttling — use a test tenant with high limits.

4. Infra and browser (4 causes)

  1. CPU-starved CI runner — raise runner size; do not add retries.
  2. Chrome version drift — pin browser version in Playwright config.
  3. Docker DNS caching — restart containers between suites.
  4. Retry masking real bugs — cap retries at 1 and quarantine on second failure.

5. Playwright fix sample — replace sleeps

// Bad
await page.waitForTimeout(3000);
await page.click('#submit');

// Good
await page.getByRole('button', { name: 'Submit' }).click();
await expect(page.getByRole('alert')).toBeVisible();

See the Playwright masterclass and Selenium interview questions for framework-specific patterns.

6. Weekly triage ritual

  1. Every Monday, list top 10 tests by flake rate.
  2. Owner assigned within 24h.
  3. Quarantine tests above 20% flake — do not run on PRs.
  4. Hard cap: quarantine expires after 5 days; test is fixed or deleted.

Reference: Google Testing Blog on flakiness.

Most of the flake we trace back to design, not infrastructure: tests written after the code, against selectors and states nobody planned for. If that sounds familiar, work through our test-driven development (TDD) guide for QA engineers — writing the assertion first removes an entire class of timing and isolation flake before it reaches CI.

Frequently asked questions

1.What flake rate is acceptable in 2026?
Under 2% is healthy, 2-5% needs attention, above 5% is a crisis.
2.Should I add retries to hide flake?
Never as a first response. Retries mask root causes and inflate CI cost.
3.Does AI self-healing fix flake?
It fixes locator drift, one of the 15 causes. It does not fix timing or isolation flake.
4.How do I measure flake rate?
(Retries on same commit) / (Total runs). Most CI dashboards expose this. If not, log per-run outcomes to your data warehouse.