-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
playwright.config.ts
125 lines (118 loc) · 4.66 KB
/
playwright.config.ts
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import { defineConfig, devices } from "@playwright/test";
import { populateEnvironment } from "@dev/build-tools";
import { getCdpEndpoint } from "./packages/tools/tests/browserstack.config";
populateEnvironment();
const isCI = !!process.env.CI;
const browserType = process.env.BROWSER || (isCI ? "Firefox" : "Chrome");
const numberOfWorkers = process.env.CIWORKERS ? +process.env.CIWORKERS : process.env.CI ? 1 : browserType === "BrowserStack" ? 1 : undefined;
const customFlags = process.env.CUSTOM_FLAGS ? process.env.CUSTOM_FLAGS.split(" ") : [];
const headless = process.env.HEADLESS !== "false";
const forceChrome = process.env.FORCE_CHROME === "true";
const browserStackBrowser = process.env.BROWSERSTACK_BROWSER || "chrome@latest:OSX Sonoma";
export default defineConfig({
// testDir: "./test/playwright",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 1,
/* Opt out of parallel tests on CI. */
workers: numberOfWorkers,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: process.env.CI ? [["line"], ["junit", { outputFile: "junit.xml" }], ["html", { open: "never" }]] : [["list"], ["html"]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
ignoreHTTPSErrors: true,
},
globalSetup: browserType === "BrowserStack" ? require.resolve("./packages/tools/tests/globalSetup.ts") : undefined,
globalTeardown: browserType === "BrowserStack" ? require.resolve("./packages/tools/tests/globalTeardown.ts") : undefined,
/* Project configuration */
projects: [
{
name: "webgl2",
testMatch: "**/*webgl2.test.ts",
use: getUseDefinition("WebGL2"),
},
// {
// name: "webgl1",
// testMatch: "**/*webgl1.test.ts",
// use: forceChrome
// ? {
// // use real chrome (not chromium) for webgpu tests
// channel: "chrome",
// headless,
// launchOptions: {
// args,
// },
// }
// : browserType === "BrowserStack"
// ? {
// connectOptions: { wsEndpoint: getCdpEndpoint(browserStackBrowser, "WebGL1") },
// }
// : {
// ...devices["Desktop " + browserType],
// headless,
// launchOptions: {
// args,
// },
// },
// },
{
name: "webgpu",
testMatch: "**/*webgpu.test.ts",
use: getUseDefinition("WebGPU"),
},
{
name: "interaction",
testMatch: "**/interaction.test.ts",
use: getUseDefinition("Interaction", "Safari", true),
},
{
name: "performance",
testMatch: "**/performance.test.ts",
use: getUseDefinition("Performance"),
},
{
name: "playground",
testMatch: "**/*.playground.test.ts",
use: getUseDefinition("Playground"),
},
],
snapshotPathTemplate: "packages/tools/tests/test/visualization/ReferenceImages/{arg}{ext}",
});
function getUseDefinition(title: string, browser = browserType, noBrowserStack = false) {
const args = browser === "Chrome" ? ["--use-angle=default", "--js-flags=--expose-gc"] : browser === "Firefox" ? ["-wait-for-browser"] : [];
args.push(...customFlags);
if (noBrowserStack) {
return {
...devices["Desktop " + browser],
headless,
launchOptions: {
args,
},
};
}
return forceChrome
? {
// use real chrome (not chromium) for webgpu tests
channel: "chrome",
headless,
launchOptions: {
args,
},
}
: browserType === "BrowserStack"
? {
connectOptions: { wsEndpoint: getCdpEndpoint(browserStackBrowser, title) },
}
: {
...devices["Desktop " + browser],
headless,
launchOptions: {
args,
},
};
}