2026-07-27 15:37:30 +08:00
|
|
|
import path from "node:path";
|
2026-07-04 13:45:47 +08:00
|
|
|
import { defineConfig, devices } from "@playwright/test";
|
2026-07-27 15:37:30 +08:00
|
|
|
import { resolvePlaywrightEndpoint, resolvePlaywrightRun } from "./tests/playwright-run.js";
|
2026-07-04 13:45:47 +08:00
|
|
|
|
2026-07-27 15:37:30 +08:00
|
|
|
const { runRoot } = resolvePlaywrightRun(__dirname, "demo");
|
|
|
|
|
const endpoint = resolvePlaywrightEndpoint("PLAYWRIGHT_DEMO_PORT", "PLAYWRIGHT_DEMO_URL", 40_000);
|
2026-07-04 13:45:47 +08:00
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
testDir: "./tests/e2e-demo",
|
|
|
|
|
timeout: 30_000,
|
|
|
|
|
expect: { timeout: 10_000 },
|
|
|
|
|
fullyParallel: false,
|
|
|
|
|
retries: process.env.CI ? 1 : 0,
|
|
|
|
|
workers: 1,
|
2026-07-27 15:37:30 +08:00
|
|
|
outputDir: path.join(runRoot, "playwright-output"),
|
|
|
|
|
reporter: process.env.CI
|
|
|
|
|
? [
|
|
|
|
|
["github"],
|
|
|
|
|
["html", { open: "never", outputFolder: path.join(runRoot, "playwright-report") }],
|
|
|
|
|
]
|
|
|
|
|
: [
|
|
|
|
|
["list"],
|
|
|
|
|
["html", { open: "never", outputFolder: path.join(runRoot, "playwright-report") }],
|
|
|
|
|
],
|
2026-07-04 13:45:47 +08:00
|
|
|
use: {
|
2026-07-27 15:37:30 +08:00
|
|
|
baseURL: endpoint.url,
|
2026-07-04 13:45:47 +08:00
|
|
|
...devices["Desktop Chrome"],
|
|
|
|
|
screenshot: "only-on-failure",
|
|
|
|
|
trace: "retain-on-failure",
|
|
|
|
|
},
|
|
|
|
|
webServer: {
|
2026-07-27 15:37:30 +08:00
|
|
|
command: `pnpm --filter @snapotter/demo build && exec pnpm --filter @snapotter/demo exec vite preview --host ${endpoint.host} --port ${endpoint.port} --strictPort`,
|
|
|
|
|
url: endpoint.url,
|
2026-07-04 13:45:47 +08:00
|
|
|
reuseExistingServer: false,
|
|
|
|
|
timeout: 60_000,
|
|
|
|
|
},
|
|
|
|
|
});
|