61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
|
|
/**
|
|
* Playwright configuration for Metamorph end-to-end tests.
|
|
*
|
|
* Run modes:
|
|
* 1. Against an already-running stack (default in CI/local):
|
|
* cd e2e && BASE_URL=http://localhost:8080 npm test
|
|
* 2. With auto-spawned dev servers — set PW_AUTOSTART=1 (see `webServer` block).
|
|
*
|
|
* Reports:
|
|
* - HTML report → `e2e/playwright-report/` (open with `npm run report`)
|
|
* - JUnit XML → `e2e/playwright-report/junit.xml` (CI ingestion)
|
|
* - Traces and screenshots are kept on retry for forensics.
|
|
*/
|
|
const BASE_URL = process.env.BASE_URL ?? 'http://localhost:8080';
|
|
const AUTOSTART = process.env.PW_AUTOSTART === '1';
|
|
|
|
export default defineConfig({
|
|
testDir: './tests',
|
|
timeout: 30_000,
|
|
expect: { timeout: 5_000 },
|
|
// The stack uses a shared Postgres. Each spec that calls /diag/reset wipes
|
|
// global state, so we must serialise execution to avoid spec-vs-spec races
|
|
// (notably the install-token reset and the per-spec admin bootstrap).
|
|
fullyParallel: false,
|
|
retries: process.env.CI ? 2 : 0,
|
|
workers: 1,
|
|
reporter: [
|
|
['list'],
|
|
['html', { outputFolder: 'playwright-report', open: 'never' }],
|
|
['junit', { outputFile: 'playwright-report/junit.xml' }],
|
|
],
|
|
use: {
|
|
baseURL: BASE_URL,
|
|
trace: 'on-first-retry',
|
|
screenshot: 'only-on-failure',
|
|
video: 'retain-on-failure',
|
|
},
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
],
|
|
// Optional: spawn the compose stack via `make up` before the tests run.
|
|
// Disabled by default — rely on the operator to bring the stack up.
|
|
...(AUTOSTART
|
|
? {
|
|
webServer: {
|
|
command: 'cd .. && make up',
|
|
url: `${BASE_URL}/api/v1/health`,
|
|
reuseExistingServer: true,
|
|
timeout: 120_000,
|
|
stdout: 'pipe',
|
|
stderr: 'pipe',
|
|
},
|
|
}
|
|
: {}),
|
|
});
|