Parallel Test Execution in CI
What you'll learn: How to configure test sharding and parallel workers to dramatically reduce CI test execution time across multiple runners.
By now, you've got Playwright tests running in GitHub Actions. But as your E2E suite grows, a single-threaded test run that took 5 minutes can balloon to 30 minutes or more. Parallel test execution splits your test suite across multiple workers, running tests simultaneously to slash total execution time.
The Bottleneck Problem
Imagine washing 100 dishes alone versus having 5 people wash 20 dishes each. The dishes get done 5x faster—same principle applies to E2E tests. Without parallelization, your CI pipeline runs tests sequentially, one after another, like a single-lane highway during rush hour.
How Playwright Handles Parallelization
Playwright has built-in parallel execution. In playwright.config.js, the workers option controls how many tests run simultaneously:
// playwright.config.js
export default {
workers: process.env.CI ? 4 : 2, // 4 parallel workers in CI
}
In CI, you can go further with test sharding—splitting the entire suite across multiple GitHub Actions runners:
# .github/workflows/playwright.yml
strategy:
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
steps:
- run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
This creates 4 separate jobs, each running 1/4 of your tests. A 20-minute suite becomes ~5 minutes.
The Trade-off
More workers = faster tests, but also more resource usage. GitHub Actions free tier has limited minutes. Balance speed against cost and available runners.
Key Takeaway: Configure parallel workers locally and test sharding in CI to transform 30-minute E2E suites into 5-minute ones, keeping your deployment pipeline fast and feedback immediate.