playwright.perf.config.ts
Linked repository file from this build.
import { defineConfig } from "@playwright/test";
import { profiles } from "./e2e/perf/measure";
import { testSecret } from "./e2e/test-secret";
const remote = process.env.QC_PERF_BASE_URL;
if (remote && !process.env.QC_PERF_STORAGE_STATE)
throw new Error(
"Remote performance runs require QC_PERF_STORAGE_STATE from a real signed-in session.",
);
const repeats = Number(process.env.QC_PERF_REPEATS ?? 3);
if (!Number.isInteger(repeats) || repeats < 1)
throw new Error("QC_PERF_REPEATS must be a positive integer.");
export default defineConfig({
testDir: "./e2e",
testMatch: /(?:perf-(budgets|instrumentation)|font-preloads)\.spec\.ts/,
workers: 1,
retries: 0,
repeatEach: repeats,
timeout: 60_000,
outputDir: "test-results/performance",
reporter: [
["list"],
["./e2e/perf/reporter.ts"],
["html", { outputFolder: "test-results/performance-report", open: "never" }],
],
projects: [
...profiles
.filter((p) => (!remote && !process.env.CI) || p.name === "local")
.map((profile) => ({
name: remote ? "remote" : profile.name,
testMatch: "perf-budgets.spec.ts",
metadata: { profile: { ...profile, name: remote ? "remote" : profile.name } },
use: { browserName: "chromium" as const },
})),
{
name: "fonts",
testMatch: "font-preloads.spec.ts",
repeatEach: 1,
use: { browserName: "chromium" as const },
},
{
name: "instrumentation",
testMatch: "perf-instrumentation.spec.ts",
repeatEach: 1,
use: { browserName: "chromium" as const },
},
],
use: {
baseURL: remote ?? "http://localhost:3001",
viewport: { width: 1440, height: 900 },
serviceWorkers: "block",
trace: process.env.QC_PERF_VISUAL === "1" ? "on" : "retain-on-failure",
video: process.env.QC_PERF_VISUAL === "1" ? "on" : "off",
storageState: remote
? process.env.QC_PERF_STORAGE_STATE
: {
cookies: [
{
name: "qc-test-secret",
value: testSecret,
domain: "localhost",
path: "/",
expires: -1,
httpOnly: false,
secure: false,
sameSite: "Lax",
},
{
name: "qc-test-staff",
value: "501",
domain: "localhost",
path: "/",
expires: -1,
httpOnly: false,
secure: false,
sameSite: "Lax",
},
],
origins: [],
},
},
webServer: remote
? undefined
: {
command: `QC_E2E_SECRET=${testSecret} bun run build && DOCUMENT_STORAGE=local QC_E2E_SECRET=${testSecret} bun run start --port 3001`,
url: "http://localhost:3001",
reuseExistingServer: false,
timeout: 180_000,
},
});