-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathplaywright.config.js
More file actions
71 lines (61 loc) · 1.96 KB
/
playwright.config.js
File metadata and controls
71 lines (61 loc) · 1.96 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
// @ts-check
const { defineConfig } = require('@playwright/test');
const e2ePort = process.env.OPENCLAW_E2E_PORT || '3000';
const e2eBase = `http://127.0.0.1:${e2ePort}`;
function isWslDrvFs() {
return process.platform === 'linux' && !!process.env.WSL_DISTRO_NAME && process.cwd().startsWith('/mnt/');
}
function resolveWorkers() {
const raw = process.env.OPENCLAW_PLAYWRIGHT_WORKERS;
if (raw) {
const parsed = Number.parseInt(raw, 10);
if (!Number.isInteger(parsed) || parsed < 1) {
throw new Error(
`OPENCLAW_PLAYWRIGHT_WORKERS must be a positive integer, got '${raw}'`,
);
}
return parsed;
}
// CRITICAL: WSL on /mnt/* has repeatable E2E harness instability under
// high parallelism; cap workers to keep the repo acceptance gate deterministic.
if (isWslDrvFs()) {
return 1;
}
return undefined;
}
function resolveTimeoutMs() {
const raw = process.env.OPENCLAW_PLAYWRIGHT_TIMEOUT_MS;
if (raw) {
const parsed = Number.parseInt(raw, 10);
if (!Number.isInteger(parsed) || parsed < 1) {
throw new Error(
`OPENCLAW_PLAYWRIGHT_TIMEOUT_MS must be a positive integer, got '${raw}'`,
);
}
return parsed;
}
// IMPORTANT: WSL on /mnt/* can push single-test wall time well past 30s even
// with one worker, especially when a spec reloads the harness inside one test.
if (isWslDrvFs()) {
return 60_000;
}
return 30_000;
}
const timeoutMs = resolveTimeoutMs();
module.exports = defineConfig({
testDir: 'tests/e2e/specs',
timeout: timeoutMs,
retries: 0,
workers: resolveWorkers(),
use: {
baseURL: `${e2eBase}/tests/e2e/`,
headless: true,
},
webServer: {
// IMPORTANT: allow overriding port for environments where 3000 is blocked/reserved.
command: `${process.env.PYTHON || (process.platform === 'win32' ? 'python' : 'python3')} -m http.server ${e2ePort}`,
url: `${e2eBase}/tests/e2e/test-harness.html`,
reuseExistingServer: true,
timeout: timeoutMs,
},
});