Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/microsoft/playwright-github-action
Run Playwright tests on GitHub Actions
https://github.com/microsoft/playwright-github-action
Last synced: 1 day ago
JSON representation
Run Playwright tests on GitHub Actions
- Host: GitHub
- URL: https://github.com/microsoft/playwright-github-action
- Owner: microsoft
- License: mit
- Created: 2020-03-04T20:37:38.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-11-15T17:33:20.000Z (about 2 months ago)
- Last Synced: 2025-01-03T17:05:40.487Z (8 days ago)
- Language: JavaScript
- Size: 124 KB
- Stars: 340
- Watchers: 16
- Forks: 49
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-playwright - playwright-github-action - GitHub Action to install all the required dependencies. (Integrations)
README
# Playwright GitHub Action
[![tests](https://github.com/microsoft/playwright-github-action/actions/workflows/tests.yml/badge.svg)](https://github.com/microsoft/playwright-github-action/actions/workflows/tests.yml)
Set up GitHub Actions to run cross-browser tests on Chromium, WebKit and Firefox with [Playwright](https://github.com/microsoft/playwright).
## ❌ You don't need this GitHub Action
**We recommend using the Playwright CLI instead of this GitHub Action**.
One of the reasons for deprecating the GitHub Actions is that it doesn't know which version of Playwright is installed,
which then requires installing many more dependencies to ensure support.We highly discourage the use of the GitHub Action. See next section for using the CLI.
## ✅ Use the Playwright CLI
Starting with Playwright v1.8.0 it [includes a CLI](https://playwright.dev/docs/cli#install-system-dependencies) that installs all required browser dependencies.
### To install dependencies with a CLI:
```sh
npx playwright install --with-deps # install browsers + dependencies for all browsers
npx playwright install chromium --with-deps # install browsers + dependencies for Chromium only
```### Playwright CLI with GitHub Actions CI
Following is an example usage of the Playwright CLI with a GitHub Actions workflow file.
It shows a `tests_e2e` job which includes steps in which the Playwright CLI invokes the
installation of required dependencies (headless browsers, etc) and then invokes the
actual npm run script `npm run test:e2e` for the Playwright test runner:```yaml
jobs:
tests_e2e:
name: Run end-to-end tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Install dependencies
run: npm ci
- name: Install playwright browsers
run: npx playwright install --with-deps
- name: Run tests
run: npx playwright test
```If something doesn't work, please [let us know](https://github.com/microsoft/playwright/issues/new)!
⚠️ GitHub Action Usage (deprecated)
Add `uses: microsoft/playwright-github-action@v1` to the GitHub workflow definition before running your tests.
```yml
on:
push:
branches:
- mainjobs:
e2e-tests:
runs-on: ubuntu-latest # or macos-latest, windows-lateststeps:
- 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](https://github.com/actions/upload-artifact) to upload test artifacts (like screenshots or logs).
```yml
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.
```sh
# Windows/macOS
npm test# Linux
xvfb-run --auto-servernum -- npm test
```
## Resources* [Get started with Playwright](https://github.com/microsoft/playwright)
* [Playwright API reference](https://playwright.dev/docs/api/class-playwright/)
* [Development docs](DEVELOPMENT.md)