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

87 lines
2.9 KiB
TypeScript

import { defineConfig, devices } from "@playwright/test";
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";
import { childProcessTimeout } from "./tests/helpers/child-process-timeout.ts";
// 1105/12-04. With TEST_RUN_ID set, this run's results, report and the build
// its preview serves are under .tmp/runs/<id>/ (scripts/lib/run-isolation.ts),
// so a second run in the same checkout neither empties this run's dist nor
// deletes its results. Unset, the paths are artifacts/tests/e2e/* and dist,
// which FE-GATE-008 and the CI upload read. The preview listens on a free
// port (TEST_E2E_PORT pins one); a fixed 4173 made the second run fail with
// "is already used".
const dist = testRunPath("dist");
const port = await reservePort(TEST_PORT_VARIABLES.e2e);
const origin = `http://127.0.0.1:${port}`;
export default defineConfig({
testDir: "./tests/e2e",
// Fixture specs build a repository copy once for the run, not once per
// browser project (tests/e2e/support/shared-fixture-builds.ts).
globalSetup: "./tests/e2e/support/e2e-global-setup.ts",
forbidOnly: true,
...ciWorkers(),
...flakyJudgement(),
outputDir: testRunPath("artifacts/tests/e2e/results"),
reporter: [
["list"],
flakyJudgementReporter,
["html", { outputFolder: testRunPath("artifacts/tests/e2e/report"), open: "never" }],
[
"junit",
{ outputFile: testRunPath("artifacts/tests/e2e/results.xml"), includeRetries: true },
],
],
use: {
baseURL: origin,
trace: "retain-on-failure",
screenshot: "only-on-failure",
},
webServer: {
env: { [RUN_OUTPUT_ROOT_VARIABLE]: testRunRoot() },
// REV-FE-0015. The wait covers the build: longest start 3,880 ms on desktop
// (2026-11-23, 3 runs), sized like a child process of a test
// (tests/helpers/child-process-timeout.ts). test:a11y inherits it.
timeout: childProcessTimeout(3_880),
command:
`corepack pnpm build && corepack pnpm preview --host 127.0.0.1 --port ${port} --strictPort --outDir ${dist}`,
url: origin,
reuseExistingServer: false,
},
projects: [
{
name: "chromium",
testIgnore: "**/compact-smoke.spec.ts",
use: { ...devices["Desktop Chrome"] },
},
{
name: "firefox",
testIgnore: "**/compact-smoke.spec.ts",
use: { ...devices["Desktop Firefox"] },
},
{
name: "webkit",
testIgnore: "**/compact-smoke.spec.ts",
use: { ...devices["Desktop Safari"] },
},
{
name: "chromium-compact",
testMatch: "**/compact-smoke.spec.ts",
use: {
...devices["Desktop Chrome"],
viewport: { width: 390, height: 844 },
hasTouch: true,
isMobile: true,
},
},
],
});