Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
105 lines (95 loc) · 2.97 KB
/
Copy pathplaywright.config.ts
File metadata and controls
105 lines (95 loc) · 2.97 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
93
94
95
96
97
98
99
100
101
102
103
104
105
import "dotenv/config";
import {
devices,
defineConfig,
PlaywrightTestConfig,
PlaywrightTestOptions,
} from "@playwright/test";
type BrowserName = "chromium" | "firefox" | "webkit";
const browserToDevice: Record<BrowserName, keyof typeof devices> = {
chromium: "Desktop Chrome",
firefox: "Desktop Firefox",
webkit: "Desktop Safari",
};
const selectedBrowser =
(process.env.WOPEE_BROWSER as BrowserName) || "chromium";
const browser = browserToDevice[selectedBrowser] ?? "Desktop Chrome";
// Extra Chromium switches, whitespace-separated — the same variable and format the
// Wopee agent reads, so one setting covers agent runs and these tests alike, e.g.
// "--auth-server-allowlist=* --auth-negotiate-delegate-allowlist=*" for Negotiate SSO.
// Chromium-only: these switches would break a Firefox or WebKit launch.
const extraBrowserArgs =
selectedBrowser === "chromium"
? (process.env.WOPEE_BROWSER_ARGS ?? "").split(/\s+/).filter(Boolean)
: [];
const projectsConfig: PlaywrightTestConfig<PlaywrightTestOptions>[] = [];
if (process.env.VIEWPORT) {
const [width, height] = process.env.VIEWPORT.toLowerCase()
.split("x")
.map(Number);
projectsConfig.push({
name: `${browser} (custom viewport)`,
use: {
...devices[browser],
viewport: { width, height },
headless: true,
},
});
} else if (process.env.WOPEE_DEVICE) {
const deviceKey = process.env.WOPEE_DEVICE as keyof typeof devices;
const device = devices[deviceKey];
let browserType: BrowserName | null =
(process.env.WOPEE_BROWSER as BrowserName | null) || null;
// Firefox does not support isMobile
if ((device.isMobile || device.hasTouch) && browserType === "firefox")
browserType = null;
projectsConfig.push({
name: `${deviceKey}${browser ? ` (${browserType})` : ""}`,
use: {
...device,
...(browserType && {
defaultBrowserType: browserType,
}),
headless: true,
},
});
} else {
projectsConfig.push({
name: `${browser} (default)`,
use: {
...devices[browser],
headless: true,
},
});
}
export default defineConfig({
testDir: ".",
testMatch: ["**/*.spec.ts"],
snapshotPathTemplate: "baselines{/projectName}/{testFilePath}/{arg}{ext}",
fullyParallel: true,
timeout: 100000,
reporter: "@wopee-io/wopee.pw/wopee-reporter",
workers: 1,
use: {
launchOptions: {
args: [
"--disable-blink-features=AutomationControlled",
...extraBrowserArgs,
],
},
baseURL: process.env.WOPEE_PROJECT_URL || "http://localhost:3000",
trace: process.env.CI ? "off" : "on-first-retry",
video: process.env.CI ? "off" : "on",
screenshot: "only-on-failure",
ignoreHTTPSErrors: true,
...(process.env.BASIC_AUTH_USER && process.env.BASIC_AUTH_PASSWORD
? {
httpCredentials: {
username: process.env.BASIC_AUTH_USER,
password: process.env.BASIC_AUTH_PASSWORD,
},
}
: {}),
},
projects: projectsConfig,
});