GitHub Actions Workflow for Playwright End-to-End Tests
Run Playwright e2e tests in CI with reports and traces.
This workflow installs Playwright browsers, runs the e2e suite, and uploads the report even when tests fail.
The workflow
.github/workflows/e2e.yml
name: E2E
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- run: npx playwright install --with-deps
- run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/Notes
--with-depsinstalls the OS libraries the browsers need.- The report uploads with
if: always()so failures are debuggable. - Shard with the matrix
--shardflag for large suites.
Run it cheaper
Point runs-on: at a Latchkey label to run this workflow at roughly 69% lower per-minute cost, with self-healing for transient failures.
Related guides
GitHub Actions Workflow Template for Node.jsA ready-to-use GitHub Actions workflow for Node.js with caching and best practices - copy, commit, and run fa…
How to Speed Up GitHub Actions: 9 High-Impact TacticsMake GitHub Actions faster: caching, parallelization, test splitting, Docker layer caching, slimmer images, a…