import { defineConfig, devices } from "@playwright/test"; import { LOCAL_BUILD_IDENTITY } from "./scripts/lib/build-environment.ts"; import { reservePort, RUN_OUTPUT_ROOT_VARIABLE, TEST_PORT_VARIABLES, testRunPath, testRunRoot, } from "./scripts/lib/run-isolation.ts"; // 1105/12-04. Under TEST_RUN_ID the results and report are the run's own // (.tmp/runs//), and so is the dev server's Vite cache. The dev server // listens on a free port (TEST_CAPABILITIES_PORT pins one); it shared 4174 // with the visual preview. Specs read the origin from `use.baseURL`. const port = await reservePort(TEST_PORT_VARIABLES.capabilities); const origin = `http://127.0.0.1:${port}`; export default defineConfig({ testDir: "./tests/browser-capabilities", forbidOnly: true, outputDir: testRunPath("artifacts/tests/browser-capabilities/results"), reporter: [ ["list"], [ "html", { outputFolder: testRunPath("artifacts/tests/browser-capabilities/report"), open: "never", }, ], [ "junit", { outputFile: testRunPath("artifacts/tests/browser-capabilities/results.xml"), }, ], ], use: { baseURL: origin, trace: "retain-on-failure", screenshot: "only-on-failure", }, 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). 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, }, projects: [ { name: "chromium", use: { ...devices["Desktop Chrome"] }, }, { name: "firefox", use: { ...devices["Desktop Firefox"] }, }, { name: "webkit", use: { ...devices["Desktop Safari"] }, }, ], });