Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
microsoft image/svg+xml

GitHub Action

Run Playwright tests

v1.5.0

Run Playwright tests

microsoft image/svg+xml

Run Playwright tests

Run Playwright tests on GitHub Actions

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Run Playwright tests

uses: microsoft/[email protected]

Learn more about this action in microsoft/playwright-github-action

Choose a version

Playwright GitHub Action

ubuntu windows macos

Set up GitHub Actions to run cross-browser tests on Chromium, WebKit and Firefox with Playwright.

⚠️ You don't need this GitHub Action ⚠️

We recommend using Playwright CLI instead of this action.

Since v1.8.0 Playwright includes CLI that installs all required browser dependencies. To install dependencies with CLI:

$ npx playwright install-deps # install dependencies for all browsers
$ npx playwright install-deps chromium # install dependencies for Chromium only

If something doesn't work, please let us know!

Usage

Add uses: microsoft/playwright-github-action@v1 to the GitHub workflow definition before running your tests.

on:
  push:
    branches:
    - main

jobs:
  e2e-tests:
    runs-on: ubuntu-latest # or macos-latest, windows-latest

    steps:
      - uses: actions/checkout@v2

      - uses: actions/setup-node@v1

      - uses: microsoft/playwright-github-action@v1

      - name: Install dependencies and run tests
        run: npm install && npm test

Upload artifacts

This GitHub Action can be combined with the Upload Artifact action to upload test artifacts (like screenshots or logs).

steps:
- uses: microsoft/playwright-github-action@v1

- name: Install dependencies and run tests
  run: npm install && npm test

- uses: actions/upload-artifact@v2
  if: ${{ always() }}
  with:
    name: test-artifacts
    path: path/to/artifacts

Run in headful mode

This GitHub Action can also execute tests in headful mode. To do this, use xvfb-run on a Linux agent.

# Windows/macOS
$ npm test

# Linux
$ xvfb-run --auto-servernum -- npm test

Resources