Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
71 lines (71 loc) · 2.69 KB
/
Copy pathplaywright.config.ts
File metadata and controls
71 lines (71 loc) · 2.69 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
import { defineConfig, devices } from "@playwright/test";
const port = process.env.E2E_PORT || "3001";
const production = !!process.env.CI || process.env.E2E_PRODUCTION === "1";
/**
* Software WebGL shares CPU with the browser and the Next server, and a
* swiftshader context alone costs well over a second to create. Everything that
* compensates for that has to travel with the renderer, not with CI: gating the
* flag on CI but the worker count and timeout on CI alone left
* E2E_SOFTWARE_GL=1 running slow software GL at full parallelism, so the one
* switch meant to reproduce CI locally was the one combination that could not.
*/
const softwareGl = !!process.env.CI || !!process.env.E2E_SOFTWARE_GL;
const sharedDemoTests = /clean-room(?:-jobs)?\.spec\.ts$/;
export default defineConfig({
testDir: "./tests/e2e",
// Aborts the run when the port is served by another checkout. See the file.
globalSetup: "./tests/e2e/global-setup.ts",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
workers: softwareGl ? 1 : 3,
timeout: softwareGl ? 60000 : 30000,
// The per-assertion timeout is separate from the per-test one above, and it
// is the one that matters here: creating a swiftshader context costs ~1.7s
// before the scene is even built, so `toHaveAttribute("data-status",
// "ready")` can outlast the 5s default while the test's own 60s budget sits
// untouched. On CI this surfaced as a first-attempt failure that the retry
// hid rather than a red build.
expect: { timeout: softwareGl ? 20000 : 5000 },
use: {
baseURL: "http://127.0.0.1:" + port,
trace: "retain-on-failure",
launchOptions: {
args: softwareGl
? ["--use-angle=swiftshader", "--enable-unsafe-swiftshader"]
: [],
},
},
projects: [
{
name: "desktop",
testIgnore: sharedDemoTests,
use: { ...devices["Desktop Chrome"] },
},
{
name: "mobile",
testIgnore: sharedDemoTests,
use: { ...devices["iPhone 13"], defaultBrowserType: "chromium" },
},
{
// These tests share the server's two-slot job pool. The admission test
// needs both slots, so UI and admission cases must not overlap.
name: "clean-room",
testMatch: sharedDemoTests,
workers: 1,
use: { ...devices["Desktop Chrome"] },
},
],
webServer: {
command:
"pnpm " +
(production ? "start" : "dev") +
// No `--` separator: pnpm forwards it to the script verbatim, and
// `next start -- --hostname` reads the flags as a project directory.
" --hostname 127.0.0.1 --port " +
port,
url: "http://127.0.0.1:" + port,
reuseExistingServer: !production,
timeout: 60000,
},
});