import { defineConfig } from "@playwright/test"; import releaseConfig from "./playwright.config.ts"; import { LOCAL_BUILD_IDENTITY } from "./scripts/lib/build-environment.ts"; import { reservePort, RUN_OUTPUT_ROOT_VARIABLE, TEST_PORT_VARIABLES, testRunRoot, } from "./scripts/lib/run-isolation.ts"; // 1105/12-04. The dev server used to reuse whatever already answered on 5173, // so the specs could run against another checkout's or another branch's dev // server without saying so. It now starts its own on a free port // (TEST_DEV_PORT pins one) and never reuses a server. const port = await reservePort(TEST_PORT_VARIABLES.dev); const origin = `http://127.0.0.1:${port}`; export default defineConfig({ ...releaseConfig, use: { ...releaseConfig.use, baseURL: origin, }, webServer: { // The dev server serves public/config.json, the local profile, whose // BUILD_ID is local-build. CI sets VITE_BUILD_ID for the whole workflow; // built into the dev bundle it makes every page a rolling-release mismatch // that reloads once and then fails closed (CONFIG_BUILD_MISMATCH). // 1105/12-04. Under TEST_RUN_ID, Vite's cache is the run's own. env: { ...LOCAL_BUILD_IDENTITY, [RUN_OUTPUT_ROOT_VARIABLE]: testRunRoot() }, command: `corepack pnpm dev --host 127.0.0.1 --port ${port} --strictPort`, url: origin, reuseExistingServer: false, }, });