Skip to content
Latchkey

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: false to 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

Run this faster and cheaper on Latchkey managed runners. Start free →