Playwright + TS · Lesson 34 of 36
Module 34: Retries & Flaky Test Management
Try it yourself
Implement classifyTestResult:
The editor has a worked example. Read it, tweak it, then press Mark as complete.
In this lesson
export default defineConfig({
// Retry 2 times on CI, 0 times locally
retries: process.env.CI ? 2 : 0,
});When a test fails on attempt 1, passes on attempt 2:
Before merging a new test into the main branch, run it in a loop 20 times:
npx playwright test tests/checkout.spec.ts --repeat-each=20If it fails even once, fix the locator or synchronization before merging!
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 + TS course (Playwright with TypeScript). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
No. Retries are a safety net to prevent blocking CI deploys on transient network glitches. Every test that retries should be diagnosed using Trace Viewer and permanently stabilized.
You can inject CSS using page.addStyleTag({ content: '* { transition: none !important; animation: none !important; }' });
Finished reading?
Review the worked example in the editor, then mark the lesson complete.