CI Optimisation and Flaky Test Management

πŸ“‹ Table of Contents β–Ύ
  1. Retries, Tagging and Reporting
  2. Common Mistakes

Even with good isolation, some flakiness is inevitable in large UI suites. Managing it proactively in CI is part of advanced test engineering: you want to detect genuine issues quickly without being overwhelmed by noisy failures.

Retries, Tagging and Reporting

Playwright supports per-test retries and powerful reporting options. Used carefully, retries can filter out transient issues while you investigate, and tagging lets you prioritise which tests run on which pipelines.

// playwright.config.ts (snippet for retries and reporter)
import { defineConfig } from '@playwright/test';

export default defineConfig({
  retries: process.env.CI ? 2 : 0,
  reporter: [['html', { outputFolder: 'playwright-report' }], ['list']],
});
// Example of tagging a test
test('critical checkout flow @smoke', async ({ page }) => {
  // ...
});

// Run only smoke tests
// npx playwright test --grep "@smoke"
Note: Retry information appears in reports, so you can see which tests are unstable even if the pipeline shows green overall.
Tip: Track flaky tests in a separate backlog and schedule regular maintenance to fix or redesign them.
Warning: Using high retry counts as a substitute for debugging root causes will erode trust in the suite.

Integrating HTML or trace-based reports into CI artifacts makes it easier for developers and testers to inspect failures quickly.

Common Mistakes

Mistake 1 β€” Treating flakiness as β€œjust how UI tests are”

This normalises poor quality.

❌ Wrong: Accepting red-to-green reruns as part of daily work.

βœ… Correct: Use retries, tagging and reports to surface flaky tests and then fix them.

Mistake 2 β€” Overusing retries without visibility

This hides instability.

❌ Wrong: Configuring retries but never reviewing which tests needed them.

βœ… Correct: Monitor retry statistics and prioritise stabilising the worst offenders.

🧠 Test Yourself

How should retries be used in Playwright CI pipelines?