Playwright CI/CD Pipeline Setup
Intermediatev1.0.0
Configure Playwright tests in CI/CD pipelines with GitHub Actions — parallel execution, artifact collection, sharding, and trace uploads for debugging failures.
Content
Overview
Running Playwright tests in CI/CD catches regressions before deployment. A properly configured pipeline runs tests in parallel across browsers, collects traces for failed tests, and provides clear reports — all within reasonable build times.
How It Works
Step 1: Configure playwright.config.ts for CI
Step 2: GitHub Actions Workflow
Step 3: Merge Sharded Reports
Best Practices
- -Use sharding to split tests across parallel CI jobs (4 shards cuts time by ~75%)
- -Set
retries: 2in CI to handle infrastructure flakiness - -Collect traces only on first retry (
trace: 'on-first-retry') to save storage - -Upload artifacts on
failure()condition for debugging - -Use
forbidOnly: truein CI to prevent.onlyfrom silently skipping tests - -Cache Playwright browsers with
actions/cachefor faster installs
Common Mistakes
- -Not installing browser dependencies (
--with-depsflag) - -Running tests sequentially instead of using sharding
- -Forgetting to upload artifacts — makes CI failures impossible to debug
- -Not setting timeouts — tests hang indefinitely on infrastructure issues
- -Using
retriesin local development (masks real failures)
FAQ
Discussion
Loading comments...