-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
78 lines (68 loc) · 2.1 KB
/
playwright.config.ts
File metadata and controls
78 lines (68 loc) · 2.1 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
import { defineConfig, devices } from "@playwright/test";
import { readFileSync } from "fs";
import { resolve } from "path";
/**
* Load .env.test for E2E session token and other test-specific env vars.
* Uses manual parsing to avoid adding dotenv dependency.
*/
try {
const envPath = resolve(__dirname, ".env.test");
const envContent = readFileSync(envPath, "utf-8");
for (const line of envContent.split("\n")) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith("#")) continue;
const eqIndex = trimmed.indexOf("=");
if (eqIndex === -1) continue;
const key = trimmed.slice(0, eqIndex).trim();
const value = trimmed.slice(eqIndex + 1).trim();
if (!process.env[key]) {
process.env[key] = value;
}
}
} catch {
// .env.test is optional — tests that need auth will warn if token missing
}
/**
* Playwright E2E configuration for Agent Studio
* @see https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
testDir: "./e2e/tests",
timeout: 60_000,
expect: { timeout: 10_000 },
/* Global setup — injects auth session cookie before all tests */
globalSetup: "./e2e/global.setup.ts",
/* Run tests sequentially — shared DB state */
fullyParallel: false,
workers: 1,
/* Fail CI if test.only is left in source */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Reporters */
reporter: process.env.CI
? [["github"], ["html", { open: "never" }]]
: [["list"], ["html", { open: "never" }]],
/* Shared settings for all projects */
use: {
baseURL: "http://localhost:3000",
storageState: "./e2e/.auth/user.json",
trace: "retain-on-first-failure",
screenshot: "only-on-failure",
video: "retain-on-failure",
},
/* Single browser project */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
/* Start Next.js dev server before tests */
webServer: {
command: process.env.CI ? "pnpm build && pnpm start" : "pnpm dev",
port: 3000,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
});