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

More Playwright tasks

Back to the full Playwright cheat sheet