Skip to content
Latchkey

How to Run Browser Tests Across Chrome and Firefox in GitHub Actions

A layout or API quirk can break Firefox while Chrome is fine; a browser matrix tests both on every PR.

Define a matrix of browser projects and run Playwright with --project per leg so each browser is a separate check.

Steps

  • Define Playwright projects for chromium and firefox in the config.
  • Use a matrix over the browser names.
  • Run playwright test --project=${{ matrix.browser }} so each browser runs independently.

Workflow

.github/workflows/browser-tests.yml
name: Browser Tests
on: [pull_request]
jobs:
  e2e:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        browser: [chromium, firefox]
    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 }}

Notes

  • Install only the browser for the matrix leg to keep each job lean.
  • On Latchkey managed runners browser test legs run cheaper and self-heal if one dies.

Related guides

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