From 174c6c001e7e18261764ce6a1d0dcce6285cd889 Mon Sep 17 00:00:00 2001 From: Johan Lundberg Date: Wed, 18 Feb 2026 11:10:23 +0100 Subject: [PATCH] feat: migrate e2e test infrastructure to @playwright/test Replace direct playwright dependency with @playwright/test and add playwright.config.js for centralized test configuration. Update run.sh to invoke 'npx playwright test' instead of running test files with node. --- tests/e2e/package-lock.json | 17 ++++++++++++++++- tests/e2e/package.json | 4 ++-- tests/e2e/playwright.config.js | 16 ++++++++++++++++ tests/e2e/run.sh | 30 +++++++----------------------- 4 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 tests/e2e/playwright.config.js diff --git a/tests/e2e/package-lock.json b/tests/e2e/package-lock.json index 2b80a34..d023504 100644 --- a/tests/e2e/package-lock.json +++ b/tests/e2e/package-lock.json @@ -6,7 +6,22 @@ "": { "name": "porchlight-e2e", "dependencies": { - "playwright": "^1.52.0" + "@playwright/test": "^1.52.0" + } + }, + "node_modules/@playwright/test": { + "version": "1.58.2", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.58.2.tgz", + "integrity": "sha512-akea+6bHYBBfA9uQqSYmlJXn61cTa+jbO87xVLCWbTqbWadRVmhxlXATaOjOgcBaWU4ePo0wB41KMFv3o35IXA==", + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.58.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" } }, "node_modules/fsevents": { diff --git a/tests/e2e/package.json b/tests/e2e/package.json index a5c3ec2..0401e36 100644 --- a/tests/e2e/package.json +++ b/tests/e2e/package.json @@ -3,10 +3,10 @@ "name": "porchlight-e2e", "description": "End-to-end browser tests for Porchlight", "scripts": { - "test": "./run.sh", + "test": "npx playwright test", "setup": "npx playwright install chromium" }, "dependencies": { - "playwright": "^1.52.0" + "@playwright/test": "^1.52.0" } } diff --git a/tests/e2e/playwright.config.js b/tests/e2e/playwright.config.js new file mode 100644 index 0000000..cd2a6e5 --- /dev/null +++ b/tests/e2e/playwright.config.js @@ -0,0 +1,16 @@ +// @ts-check +const { defineConfig } = require('@playwright/test'); + +module.exports = defineConfig({ + testDir: '.', + testMatch: '*.spec.js', + timeout: 30_000, + retries: 0, + workers: 1, + reporter: [['list']], + use: { + baseURL: process.env.TARGET_URL || 'http://localhost:8099', + browserName: 'chromium', + headless: process.env.E2E_HEADLESS !== '0', + }, +}); diff --git a/tests/e2e/run.sh b/tests/e2e/run.sh index 3976c4d..774343d 100755 --- a/tests/e2e/run.sh +++ b/tests/e2e/run.sh @@ -61,30 +61,14 @@ export E2E_FIXTURES echo "Test fixtures: ${E2E_FIXTURES}" # --- Run tests --- -FAILED=0 - -if [ $# -gt 0 ]; then - TEST_FILES=("$@") -else - TEST_FILES=("$SCRIPT_DIR"/test_*.js) -fi - -for test_file in "${TEST_FILES[@]}"; do - echo "" - echo "=== Running $(basename "$test_file") ===" - if node "$test_file"; then - echo "=== $(basename "$test_file"): OK ===" - else - echo "=== $(basename "$test_file"): FAILED ===" - FAILED=1 - fi -done - echo "" -if [ "$FAILED" -eq 0 ]; then - echo "All e2e tests passed." +echo "=== Running Playwright tests ===" +cd "$SCRIPT_DIR" +if [ $# -gt 0 ]; then + npx playwright test "$@" else - echo "Some e2e tests failed." >&2 + npx playwright test fi +EXIT_CODE=$? -exit "$FAILED" +exit "$EXIT_CODE"