Intermediate2 min readMay 18, 2025
Playwright E2E Tests in GitHub Actions
Set up a fully parallelized Playwright test suite in GitHub Actions with sharding, caching, and HTML reports.
Overview
The goal is not just “run Playwright in CI.” The real goal is fast and trustworthy feedback with artifacts that make failures easy to debug.
Prerequisites
- Playwright test suite already running locally
- GitHub Actions enabled for the repository
- a clear definition of which tests are allowed to block merges
Base workflow
yaml
19 lines
1name: e2e23on:4 pull_request:5 push:6 branches: [main]78jobs:9 test:10 runs-on: ubuntu-latest11 steps:12 - uses: actions/checkout@v413 - uses: actions/setup-node@v414 with:15 node-version: 2216 - run: corepack enable17 - run: pnpm install --frozen-lockfile18 - run: pnpm exec playwright install --with-deps19 - run: pnpm exec playwright testAdd sharding
Sharding matters once runtime begins slowing delivery velocity. It should be introduced only after the suite is stable enough that parallelism does not amplify flakiness.
Cache carefully
- cache the package manager store
- do not assume browser caches alone solve most runtime cost
- keep install and test logs visible
Publish artifacts
HTML reports, traces, screenshots, and videos reduce time-to-fix dramatically when a CI run fails.
yaml
6 lines
1- name: Upload report2 if: always()3 uses: actions/upload-artifact@v44 with:5 name: playwright-report6 path: playwright-reportSummary
Good CI for Playwright is a reliability system: repeatable environment, stable parallelism, and useful debugging output.