Files
Mangalord/frontend/playwright.config.ts
MechaCat02 ded77fe4ba test(e2e): kill cold-start flakiness with an /api/v1 fallback + one retry
A full parallel run intermittently failed the first few tests: unmocked
/api/v1 calls fell through to the dev proxy, whose backend isn't running
under E2E, so each incurred a slow ECONNREFUSED round-trip + Vite error
logging that piled up across 8 workers at cold start.

- Add e2e/fixtures.ts: a shared `test` whose auto-use fixture installs an
  `**/api/v1/**` fallback (fast 503, logged) for any endpoint a spec
  didn't mock. Registered before the test body, so per-test routes still
  win; only genuine gaps land here. Turns silent mock-gap hangs into
  instant, attributable failures — and cuts the full run ~96s → ~25s.
- Point all 22 specs at ./fixtures instead of @playwright/test.
- retries: 1 in the config as a safety net for the residual Vite
  cold-compile timing (re-runs on the now-warm server).

Two consecutive full runs: 110 passed, 0 flaky, no retries consumed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 20:06:20 +02:00

34 lines
1.4 KiB
TypeScript

import { defineConfig } from '@playwright/test';
// Playwright runs the SvelteKit dev server on a dedicated port so it
// doesn't reuse whatever the dev workflow has on the vite default
// (`5173`). `--strictPort` makes vite fail fast on collision instead of
// silently bumping to a free port, which would leave Playwright pointed
// at the wrong host. Set `E2E_BASE_URL` to skip the embedded server and
// point at an already-running deployment.
const E2E_PORT = 5174;
export default defineConfig({
testDir: 'e2e',
timeout: 30_000,
// The specs are deterministic in isolation, but a full parallel run
// has a cold-start window: Vite compiles each route on first request,
// so the first tests across 8 workers contend on the dev server and
// can trip the timeout. One retry re-runs those on the now-warm server.
// (The `/api/v1` fallback in e2e/fixtures.ts removes the other flake
// source — unmocked calls stalling against the dead dev proxy.)
retries: 1,
use: {
baseURL: process.env.E2E_BASE_URL ?? `http://localhost:${E2E_PORT}`,
trace: 'retain-on-failure'
},
webServer: process.env.E2E_BASE_URL
? undefined
: {
command: `npm run dev -- --port ${E2E_PORT} --strictPort`,
port: E2E_PORT,
reuseExistingServer: !process.env.CI,
timeout: 120_000
}
});