120 / 139 · 13 Browser Automation with Playwright · Parallel Execution and Reporting← prev⊞ allnext →☰ Read as one page
14.3Sharding Across CI Machines
For large suites, split execution across multiple CI machines:
# Machine 1: runs first quarter of tests
npx playwright test --shard=1/4
# Machine 2: runs second quarter
npx playwright test --shard=2/4
# Machine 3: runs third quarter
npx playwright test --shard=3/4
# Machine 4: runs last quarter
npx playwright test --shard=4/4
GitHub Actions Example
# .github/workflows/e2e.yml
jobs:
test:
strategy:
matrix:
shard: [1/4, 2/4, 3/4, 4/4]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci
- run: npx playwright install --with-deps
- run: npx playwright test --shard=${{ matrix.shard }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.shard }}
path: test-results/