October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Run Playwright Tests in GitHub Actions

A practical guide to installing Playwright browsers, running stable GitHub Actions tests, scaling with shards, and retrieving reports and traces.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To run Playwright tests in GitHub Actions, install your project dependencies, install the matching Playwright browsers and operating-system packages, run the tests, then upload the report as an artifact. Start with one worker for reliable CI runs; use a sharded job matrix when you need to distribute a large suite across runners.

Set up a basic GitHub Actions workflow

This workflow follows the sequence in Playwright’s Continuous Integration guide. It is an example, not a tested workflow: adapt the package commands to your project, and make sure your reporter writes to the artifact path.

name: Playwright Tests
on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]
jobs:
  test:
    timeout-minutes: 60
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: lts/*
      - run: npm ci
      - run: npx playwright install --with-deps
      - run: npx playwright test
      - uses: actions/upload-artifact@v5
        if: ${{ !cancelled() }}
        with:
          name: playwright-report
          path: playwright-report/
          retention-days: 30

The 60-minute timeout and 30-day artifact retention are values shown in Playwright’s example, not universal requirements. Action version tags and repository retention policies can change, so follow your organization’s policy. If you use a different package manager, substitute its lockfile-based install command for npm ci.

Keep the report path consistent

The workflow uploads playwright-report/. Configure Playwright’s HTML reporter to generate that directory, or change the artifact path to match your reporter output. The !cancelled() condition allows the upload after a failed test step while avoiding uploads after cancellation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install browser binaries and system dependencies

Playwright browser binaries are tied to Playwright package releases. After changing the Playwright version, install browsers again so the binaries match. The standard command installs supported browsers and their required operating-system packages:

npx playwright install --with-deps

If the suite only uses Chromium, install just that browser to reduce unnecessary downloads and disk use:

npx playwright install chromium --with-deps

Choose Chromium, Firefox, WebKit, or branded browser channels according to the browsers your product needs to support. Playwright’s browser documentation explains browser installation and version matching.

Direct installation or a container

Approach How it works Trade-off
Install on the runner Use the runner’s operating-system image, then install project dependencies and browsers in the job. Straightforward and aligned with the hosted runner, but downloads and OS dependencies are part of each job.
Use a Playwright container Run the job in a Playwright image with its browsers and dependencies; omit the separate browser-install step when the image supplies them. Provides a more controlled browser environment, but the image tag and Playwright package version must be kept in sync.

Playwright’s CI documentation illustrates a container using mcr.microsoft.com/playwright:v1.63.0-noble. That is the tag in its example, not a guarantee that it is the latest image. Select and update image and package versions deliberately.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make test runs stable before optimizing speed

Playwright recommends setting CI workers to 1 to prioritize stability and reproducibility. More workers on one runner can increase resource contention and timeouts. A self-hosted runner with spare capacity may support more workers, but measure the effect rather than assuming more concurrency will finish sooner.

Retries can help expose intermittent failures, but they do not fix flaky tests. The configuration guide shows CI-only retries, one worker in CI, forbidOnly in CI, HTML reporting, and trace: 'on-first-retry' as configuration examples. Treat these as options to tune for your suite, not required values.

retries: process.env.CI ? 2 : 0

For a long suite, distribute work across jobs instead of simply increasing workers on a single runner.

Parallelize a large suite with sharding

Sharding assigns portions of a test suite to separate jobs. A matrix can provide each job a shard index and total, with the test command using those values:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}

Each shard can produce a blob report. Upload those reports as artifacts, collect them in a downstream job, and merge them into one HTML report:

npx playwright merge-reports --reporter html ./all-blob-reports

This approach distributes the suite across machines but adds artifact collection and a report-merging stage. Playwright’s sharding guide documents the matrix, blob-report, and merge pattern; that URL is under the next documentation path and may change before general release.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Get useful reports and diagnose failures

Upload the HTML report even when tests fail so the failure is available after the runner exits. In a sharded workflow, merge the per-job blob reports first to inspect the suite in a consolidated report.

  • Browser launch failure: set DEBUG=pw:browser to emit browser-launch logs, as suggested in the CI guide.
  • Headed tests on Linux: provide Xvfb and run the test command with xvfb-run, for example xvfb-run npx playwright test. Playwright’s Docker image and GitHub Action have Xvfb preinstalled.
  • Intermittent failure: enable trace collection on a retry, then inspect the trace alongside the report rather than treating a passing retry as a fix.

Reports and traces may contain authenticated pages, test data, or internal application content. The Playwright CI documentation warns that these artifacts can expose sensitive information. Upload them only to trusted artifact storage or encrypt them before upload.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose between a full run, changed-test pre-pass, and deployment tests

Changed tests are a fast first signal, not a replacement for the suite

Playwright’s changed-test CI guidance describes --only-changed as a heuristic based on dependency relationships. It can miss affected tests, so use it as a preliminary check and follow it with a full suite run. Its example requires a non-shallow checkout so the workflow can compare against the pull request’s base ref.

Run end-to-end tests against a deployment

If tests should target a preview deployment rather than a locally started application, Playwright documents running after a successful GitHub deployment status and setting the test base URL to the deployment target URL. The configuration guide also shows baseURL and webServer for tests that start a local app before running. Choose the pattern that matches where the application is available; deployment-specific workflow details depend on your repository.

Should you cache browser binaries?

Playwright does not recommend caching browser binaries by default: its CI guidance says cache restoration can take about as long as downloading the binaries, and Linux system dependencies cannot be cached. Prefer installation unless measurements in your environment show caching saves time. If you do cache browsers, include the Playwright version in the cache key to avoid reusing binaries after a package upgrade.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.