Skip to content
Latchkey

How to Run Playwright Tests in CI on GitHub Actions

Playwright runs headless by default in CI; the one required extra step is installing the browsers with their system libraries.

Install dependencies, run npx playwright install --with-deps to fetch browsers plus their OS packages, execute the suite, then upload playwright-report/ so failures are inspectable.

Steps

  • Check out the repo and set up Node with a dependency cache.
  • Run npx playwright install --with-deps to install browsers and OS libraries.
  • Run npx playwright test (headless is the default in CI).
  • Upload playwright-report/ with if: always() so it exists even on failure.

Workflow

.github/workflows/ci.yml
jobs:
  e2e:
    runs-on: ubuntu-latest
    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
      - run: npx playwright test
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: playwright-report
          path: playwright-report/
          retention-days: 7

Gotchas

  • Without --with-deps you hit missing shared library errors like libnss3; the flag installs those packages.
  • Set reporter: [['html']] in the config so the uploaded folder contains a browsable report.
  • Latchkey runs these browser jobs on managed runners that auto-retry transient install failures.

Related guides

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