Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
92 lines (85 loc) · 2.39 KB
/
Copy pathplaywright.config.ts
File metadata and controls
92 lines (85 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { defineConfig } from "@playwright/test";
import path from "node:path";
import { accessSync, constants } from "node:fs";
function loadEnvironmentFromFiles(): void {
const loadEnvFile = (
process as typeof process & {
loadEnvFile?: (file?: string) => void;
}
).loadEnvFile;
if (typeof loadEnvFile !== "function") {
return;
}
for (const envFile of [".env.local", ".env"]) {
const absolutePath = path.resolve(process.cwd(), envFile);
try {
accessSync(absolutePath, constants.F_OK);
loadEnvFile(absolutePath);
} catch {
// Ignore missing env files in CI/workflows that rely on injected env vars.
}
}
}
loadEnvironmentFromFiles();
if (
!process.env.CLERK_PUBLISHABLE_KEY &&
process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
) {
process.env.CLERK_PUBLISHABLE_KEY =
process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY;
}
const baseURL = process.env.E2E_BASE_URL ?? "http://localhost:3000";
const defaultWebServerCommand = "npm run build && npm run start -- --port 3000";
const webServerCommand =
process.env.PLAYWRIGHT_WEB_SERVER_COMMAND ?? defaultWebServerCommand;
const billingWorkers = Number.parseInt(
process.env.CI ? (process.env.PLAYWRIGHT_WORKERS ?? "1") : "1",
10,
);
if (!Number.isSafeInteger(billingWorkers) || billingWorkers < 1) {
throw new Error("PLAYWRIGHT_WORKERS must be a positive integer");
}
export default defineConfig({
testDir: "./e2e",
timeout: 120_000,
expect: {
timeout: 15_000,
},
fullyParallel: false,
retries: process.env.CI ? 2 : 0,
maxFailures: process.env.CI ? 1 : undefined,
workers: process.env.CI ? billingWorkers : undefined,
reporter: process.env.CI ? [["github"], ["html", { open: "never" }]] : "list",
globalSetup: "./e2e/global.setup.ts",
webServer: {
command: webServerCommand,
env: { PLAYWRIGHT_TEST_PROXY: "1" },
url: baseURL,
// The server must start with Next's test proxy enabled.
reuseExistingServer: false,
stdout: "pipe",
stderr: "pipe",
timeout: 300_000,
},
use: {
baseURL,
trace: "retain-on-failure",
screenshot: "only-on-failure",
video: "retain-on-failure",
},
projects: [
{
name: "default",
testIgnore: "**/billing/**",
},
{
name: "billing",
testDir: "./e2e/billing",
timeout: 180_000,
fullyParallel: billingWorkers > 1,
use: {
locale: "en-US",
},
},
],
});