Configuring Retries in Playwright
From the Playwright cheat sheet ยท Retries & Timeouts ยท verified Jul 2026
Configuring Retries
Automatically retry failed tests to handle flaky behavior
typescript
import { defineConfig } from '@playwright/test';
export default defineConfig({
retries: process.env.CI ? 2 : 0, // Retry twice on CI
});๐ก Retries re-run the entire test including beforeEach hooks โ each retry gets a clean state
โก Traces with "on-first-retry" only record when a test fails and retries โ saving disk space
๐ Use testInfo.retry to detect retries and add conditional cleanup or logging
๐ข Set retries: 0 locally for fast feedback, retries: 2 on CI for stability
retriesflaky