Quick Start

Running Playwright tests in Parallel in GitHub Actions using Matrix Workflow

Quick Start

The example workflow file below shows how to run Playwright tests in GitHub actions.

name: demo.playwright.pwc
on:
  workflow_dispatch:
  pull_request:
    branches: [main]
  push:
    branches: [main]
jobs:
  run-tests:
    name: "Playwright Tests"
    timeout-minutes: 60
    runs-on: ubuntu-22.04
    container: mcr.microsoft.com/playwright:v1.49.0-jammy

    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}

      # https://github.com/actions/runner-images/issues/6775
      - run: |
          echo "$GITHUB_WORKSPACE"
          git config --global --add safe.directory "$GITHUB_WORKSPACE"

      - uses: actions/setup-node@v4
        with:
          node-version: "20.x"

      - name: Install dependencies
        run: | # Add more browsers if needed
          npm ci
          npx playwright install chrome

      - name: Playwright Tests
        continue-on-error: false
        env:
          CURRENTS_PROJECT_ID: bnsqNa # Update to your Project ID
          CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
        run: |
          npx pwc

The workflow above is the simplest way to get started. As you scale, using parallelization becomes very important to keep execution time fast.

Parallelization

By using GitHub Actions matrix execution strategyarrow-up-right, you can create multiple containers that will run your Playwright tests in parallel.

Each container will receive a unique set of tests to run so that your tests will run faster and you can receive faster feedback from your browser test suite.

Tests Parallelization with Github Actions

You can achieve that through Playwright Shardingarrow-up-right. Playwright supports splitting the tests between multiple CI machines using --shard CLI flag. Below you can find examples on how to setup sharding, and orchestration.

circle-info

Looking for more ways to speed up CI? Read our CI Optimization page.

Examples

The example repositoryarrow-up-right showcases running Playwright tests in GitHub Actions. We've included several config files to exemplify the workflows:

Last updated

Was this helpful?