Files
ipal-kit/reference/playwright.config.ts
T
Radosław SmolińskiandClaude Fable 5.2 81cee02e78 M1: the reference e2e suite follows the stored 2FA verify count
The verify count now survives a restart of the site, so the specs can no longer
share one test admin across server runs: create-test-admin.ts makes two test
admins and clears their stored counts; the setup spec signs in as the second.
The whole suite passes in one run (20 passed, 1 skipped).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:23 +01:00

34 lines
1.3 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test'
// .env holds the E2E_* test values locally; CI passes them as env
try {
process.loadEnvFile('.env')
} catch {
// no .env (CI)
}
/**
* Smoke tests against a built, seeded site: pnpm build && pnpm seed && pnpm payload run e2e/create-test-admin.ts.
* Run create-test-admin.ts again before repeating the tests within ten minutes: the 2FA verify limit (5 attempts per
* account in 10 minutes) is stored in the database, and that script clears the test admins' counts.
* E2E_BASE_URL picks the port (default 3100). Playwright starts its own server there and fails when the port is
* taken, so another project's dev server is never tested by mistake; E2E_REUSE_SERVER=1 uses a server you started.
*/
const baseURL = process.env.E2E_BASE_URL ?? 'http://localhost:3100'
export default defineConfig({
forbidOnly: !!process.env.CI,
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
reporter: process.env.CI ? 'line' : 'list',
retries: process.env.CI ? 1 : 0,
testDir: './e2e',
use: { baseURL, trace: 'retain-on-failure' },
webServer: {
command: 'pnpm start',
env: { PORT: new URL(baseURL).port || '3000' },
reuseExistingServer: process.env.E2E_REUSE_SERVER === '1',
url: `${baseURL}/api/health`,
},
workers: 1,
})