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
How to Test Against Multiple Node and OS Combos in GitHub ActionsRun tests across multiple Node versions and operating systems in GitHub Actions with a matrix so version- and…
How to Run E2E Tests with Playwright and Upload Traces in GitHub ActionsRun Playwright end-to-end tests in GitHub Actions and upload traces and reports as artifacts on failure so yo…