How to Test Across a Browser Matrix in GitHub Actions
Drive Playwright --project from a matrix dimension to run the same suite once per browser engine.
List the browser engines in strategy.matrix.browser and pass --project=${{ matrix.browser }}, mapping each to a project defined in the Playwright config.
Steps
- Define chromium, firefox, and webkit projects in the config.
- Add a
browser:matrix dimension. - Run
npx playwright test --project=${{ matrix.browser }}. - Set
fail-fast: falseto see every browser result.
Workflow
.github/workflows/ci.yml
jobs:
e2e:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
browser: [chromium, firefox, webkit]
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 ${{ matrix.browser }}
- run: npx playwright test --project=${{ matrix.browser }}Gotchas
- Installing only the matrix browser (
install --with-deps chromium) is faster than installing all three per job. - WebKit on Linux differs from Safari on macOS; test real Safari separately if it matters.
Related guides
How to Test Multiple Viewports in E2E on GitHub ActionsTest mobile and desktop viewports in a single Playwright E2E run on GitHub Actions by defining device project…
How to Run Headed Browser Tests With Xvfb in GitHub ActionsRun headed browser tests on a headless GitHub Actions runner by wrapping the command in xvfb-run, which provi…