AI Test Stack
All Tutorials
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: e2e
2
3on:
4 pull_request:
5 push:
6 branches: [main]
7
8jobs:
9 test:
10 runs-on: ubuntu-latest
11 steps:
12 - uses: actions/checkout@v4
13 - uses: actions/setup-node@v4
14 with:
15 node-version: 22
16 - run: corepack enable
17 - run: pnpm install --frozen-lockfile
18 - run: pnpm exec playwright install --with-deps
19 - run: pnpm exec playwright test

Add 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 report
2 if: always()
3 uses: actions/upload-artifact@v4
4 with:
5 name: playwright-report
6 path: playwright-report

Summary

Good CI for Playwright is a reliability system: repeatable environment, stable parallelism, and useful debugging output.