Skip to content

Instantly share code, notes, and snippets.

@PascalPixel
Created September 27, 2022 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PascalPixel/da5d69a3b89b11efc452a842afb20a84 to your computer and use it in GitHub Desktop.
Save PascalPixel/da5d69a3b89b11efc452a842afb20a84 to your computer and use it in GitHub Desktop.
GitHub Action Playwright Vercel
# .github/workflows/playwright.yml
# This is a Playwright testing workflow for GitHub Actions
name: Playwright Tests
# Controls when the workflow will run
on:
# Triggers the workflow on Vercel deploy events
deployment_status:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "test"
test:
# Only run if deployment was succesful and branch is not master
if: github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'Preview'
# Prevent GitHub Actions overload
timeout-minutes: 10
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Add Node 16 to the build
- uses: actions/setup-node@v3
with:
node-version: 16
# Installs the dependencies for your project
- name: Install dependencies
run: npm ci
# Installs browsers
- name: Install Playwright Browsers
run: npx playwright install --with-deps
# Runs the tests using the URL from Vercel
- name: Run Playwright tests
run: npm run test:e2e
env:
PLAYWRIGHT_TEST_BASE_URL: ${{ github.event.deployment_status.target_url }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment