Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: E2E Tests

on:
pull_request:
push:
branches: [trunk]

jobs:
e2e:
name: E2E Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: pnpm/action-setup@v4
with:
version: latest

- uses: actions/setup-node@v4
with:
node-version: '20'
cache: pnpm
cache-dependency-path: tests/e2e/pnpm-lock.yaml

- name: Install dependencies
working-directory: tests/e2e
run: pnpm install --frozen-lockfile

- name: Start Docker environment
working-directory: tests/e2e
run: docker compose up -d --build --wait

- name: Wait for WordPress
run: |
echo "Waiting for WordPress to be ready..."
for i in $(seq 1 30); do
if curl -sf http://localhost:2022/ > /dev/null 2>&1; then
echo "WordPress is ready."
exit 0
fi
echo "Attempt $i/30 - waiting 5s..."
sleep 5
done
echo "WordPress did not become ready in time."
docker compose -f tests/e2e/docker-compose.yml --project-directory tests/e2e logs
exit 1

- name: Run e2e tests
working-directory: tests/e2e
run: pnpm test:run

- name: Docker logs
if: failure()
working-directory: tests/e2e
run: docker compose logs

- name: Tear down Docker environment
if: always()
working-directory: tests/e2e
run: docker compose down -v
2 changes: 1 addition & 1 deletion tests/e2e/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fileURLToPath } from 'url';
import { config as dotenvConfig } from 'dotenv';

// Read .env file so variables are available in tests.
dotenvConfig( { path: fileURLToPath( '.env', import.meta.url ) } );
dotenvConfig( { path: fileURLToPath( new URL( '.env', import.meta.url ) ) } );

export default {
preset: 'ts-jest',
Expand Down
8 changes: 6 additions & 2 deletions tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"type": "module",
"scripts": {
"build": "pnpm jetpack build plugins/super-cache -v --no-pnpm-install --production",
"build": "echo 'No build needed'",
"clean": "rm -rf output",
"distclean": "rm -rf node_modules",
"env:down": "docker-compose down",
Expand All @@ -11,12 +11,16 @@
"test:run": "jest --runInBand",
"typecheck": "tsgo --noEmit"
},
"pnpm": {
"onlyBuiltDependencies": [
"unrs-resolver"
]
},
"devDependencies": {
"@jest/globals": "^30.0.0",
"@types/node": "^24.12.0",
"@types/shell-escape": "0.2.3",
"@typescript/native-preview": "7.0.0-dev.20260225.1",
"_jetpack-e2e-commons": "workspace:*",
"axios": "1.13.5",
"cheerio": "1.2.0",
"domhandler": "5.0.3",
Expand Down
Loading
Loading