import { defineConfig, devices } from "@playwright/test"; import { portFor } from "yt-dlp-transcript-common/lib/ports.mjs"; import { REPORT_SITE_OUT, stageReportSite } from "./e2e-report/stage"; // Test-only environment (declared in common/lib/envVars.ts): // E2E_REPORT_SITE_REUSE=1 serve the stage's existing build instead of // building again (iterating on the specs alone). // The CITED report-site suite: a real static export of a cited fixture site // (one fact-check citing every kind, its moments, their media), staged and // built OUTSIDE export/ — e2e-report/stage.ts says why — and served as Pages // serves a deployed site (scripts/serve-out.mjs; not `serve`, which lists a // span moment's directory instead of serving its page). What the specs see is // what a cited build ships, and audit.spec.ts holds the same out/ to the cited // allowlist audit. // // Its own suite (`pnpm --filter export run e2e:report`), never part of the // default export suite (testDir ./e2e) nor of the editor's `pnpm e2e`. Staged // here at config load, before the webServer starts, and once — in the runner, // not again in each worker (Playwright sets TEST_WORKER_INDEX there). const PORT = portFor("REPORT_SITE_E2E_PORT"); const baseURL = `http://localhost:${PORT}`; if (!process.env.TEST_WORKER_INDEX) { stageReportSite({ reuse: process.env.E2E_REPORT_SITE_REUSE === "1" }); } export default defineConfig({ testDir: "./e2e-report", timeout: 30_000, retries: process.env.CI ? 2 : 0, // `json` beside `list`: the run's timing record, which // scripts/e2e-timings.mjs totals per spec against the branch's last run. reporter: process.env.CI ? "github" : [["list"], ["json", { outputFile: "test-results-report/timings.json" }]], outputDir: "test-results-report/", fullyParallel: false, workers: 1, webServer: { command: `node scripts/serve-out.mjs ${REPORT_SITE_OUT} ${PORT}`, url: `${baseURL}/site.json`, timeout: 60_000, reuseExistingServer: !process.env.CI, }, use: { baseURL, trace: "on-first-retry", screenshot: "only-on-failure", video: "retain-on-failure", }, projects: [ { name: "chromium", use: { ...devices["Desktop Chrome"], viewport: { width: 1440, height: 1000 } }, }, ], });