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-depsto install browsers and OS libraries. - Run
npx playwright test(headless is the default in CI). - Upload
playwright-report/withif: 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: 7Gotchas
- Without
--with-depsyou hit missing shared library errors likelibnss3; 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
How to Shard Playwright Tests Across a Matrix in GitHub ActionsSplit a Playwright suite across parallel GitHub Actions jobs with --shard and a matrix, then merge the blob r…
How to Upload Playwright Traces and Videos on Failure in GitHub ActionsCapture Playwright traces, videos, and screenshots only on failed retries, then upload them as GitHub Actions…