Skip to content

Playwright testing

Playwright testing #14

Workflow file for this run

name: Playwright Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
# Explicitly set security permissions.
permissions: {}
jobs:
test:
name: Run E2E Tests
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
- name: Install dependencies
run: npm ci
- name: Create docker-compose alias for Docker Compose v2
run: |
# Create a wrapper script that forwards arguments to "docker compose"
echo '#!/bin/sh
docker compose "$@"' | sudo tee /usr/local/bin/docker-compose
# Make the script executable
sudo chmod +x /usr/local/bin/docker-compose
# Cache Playwright browsers to speed up subsequent runs.
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
# Only install browsers if cache miss occurred.
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install chromium --with-deps
# Install and configure WordPress environment.
- name: Install WordPress Environment
run: npm install -g @wordpress/env
# Start WordPress environment and wait for it to be ready.
- name: Start WordPress Environment
run: |
npx wp-env start
sleep 10
npx wait-on http://localhost:8889
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-${{ github.run_id }}
path: playwright-report/
retention-days: 30