Files
clean-architecture-frontend…/playwright.capabilities.config.ts

75 lines
2.3 KiB
TypeScript

import { defineConfig, devices } from "@playwright/test";
import { LOCAL_BUILD_IDENTITY } from "./scripts/lib/build-environment.ts";
import { ciWorkers } from "./scripts/lib/playwright-ci-workers.ts";
import { flakyJudgement, flakyJudgementReporter } from "./scripts/lib/playwright-flaky-judgement.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/<id>/), 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,
...ciWorkers(),
...flakyJudgement(),
outputDir: testRunPath("artifacts/tests/browser-capabilities/results"),
reporter: [
["list"],
flakyJudgementReporter,
[
"html",
{
outputFolder: testRunPath("artifacts/tests/browser-capabilities/report"),
open: "never",
},
],
[
"junit",
{
outputFile: testRunPath("artifacts/tests/browser-capabilities/results.xml"),
includeRetries: true,
},
],
],
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"] },
},
],
});