-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
60 lines (54 loc) · 2.41 KB
/
Copy pathplaywright.config.ts
File metadata and controls
60 lines (54 loc) · 2.41 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
import { defineConfig } from "@playwright/test";
import { existsSync, readFileSync } from "fs";
import { resolve } from "path";
// Load .env.local (not checked in) for local overrides like SCREEN_X
const _envLocal = resolve(__dirname, ".env.local");
if (existsSync(_envLocal)) {
for (const line of readFileSync(_envLocal, "utf-8").split("\n")) {
const m = line.match(/^\s*([^#=]+?)\s*=\s*(.*?)\s*$/);
if (m && !process.env[m[1]]) {
process.env[m[1]] = m[2];
}
}
}
const screenX = process.env.SCREEN_X;
const headless = process.env.HEADLESS === "true";
const isCI = !!process.env.CI;
// REUSE_BROWSER=true (see tests/lite/parity/parity-fixtures.ts) makes every scene
// parity spec in a worker share ONE reused page/window instead of opening a fresh
// browser window per test. In headed local runs this keeps a single window in the
// background rather than popping hundreds of windows to the foreground.
// Tests run their OWN isolated Vite dev server on a dedicated port — NOT the
// interactive lab (5174). Sharing that server made the lab unresponsive during
// test runs (its single Node event loop was busy transforming/serving scene
// modules to the headless test browsers). Override with LAB_TEST_PORT if needed.
const labTestPort = Number(process.env.LAB_TEST_PORT ?? 5179);
// SwiftShader flags — only in CI (locally we use the real GPU)
const swiftShaderArgs = isCI
? ["--enable-features=Vulkan", "--use-vulkan=swiftshader", "--use-angle=swiftshader", "--disable-vulkan-fallback-to-gl-for-testing", "--ignore-gpu-blocklist"]
: [];
export default defineConfig({
testDir: "./tests",
testIgnore: ["**/unit/**", "**/compat/**"],
timeout: 60_000,
retries: 2,
workers: 2,
// On CI, bail on the first failing test (after its retries) to save time;
// locally we keep running so devs see every failure in one pass.
maxFailures: isCI ? 1 : undefined,
use: {
channel: "chrome",
headless,
viewport: { width: 1280, height: 720 },
launchOptions: {
args: ["--force-color-profile=srgb", "--enable-unsafe-webgpu", ...swiftShaderArgs, ...(screenX ? [`--window-position=${screenX},0`] : [])],
},
},
webServer: {
command: "pnpm --filter @babylon-lite/lab dev",
port: labTestPort,
env: { LAB_DEV_PORT: String(labTestPort) },
reuseExistingServer: true,
timeout: 30_000,
},
});