Playwright + JS · Lesson 34 of 35

0/35 done

Module 34: Retries & Flaky Test Management

34. Flaky Test Elimination & Retry Strategy

16 minlesson

Try it yourself

Implement classifyOutcome:

  1. Accept attempts (number) and passed (boolean).
  2. Return "FAILED" if !passed; "FLAKY" if attempts > 1 and passed; otherwise "PASSED".

The editor has a worked example. Read it, tweak it, then press Mark as complete.

Retrying Tests in playwright.config.js

javascript
export default {
  retries: process.env.CI ? 2 : 0,
};

Stress test for flakiness locally:

bash
npx playwright test tests/checkout.spec.js --repeat-each=20

Key Takeaways & Walkthrough Summary

Flaky tests erode team confidence in test automation. In this lesson, we will explore the root causes of flakiness, configure intelligent retry strategies for CI pipelines, and use Playwright tools to identify, isolate, and permanently eliminate flaky tests. Let's build rock-solid stability!

Part of the Playwright + JS course (Playwright with JavaScript). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.

Common Doubts & Lesson Q&A

Are retries a permanent solution for flaky tests?

No. Retries prevent blocking CI pipelines on transient network glitches. Every flaky test should be diagnosed and stabilized using Trace Viewer.

Finished reading?

Review the worked example in the editor, then mark the lesson complete.

JavaScript
Skip