Repository navigation
Expand file tree
/
Copy pathwdio.conf.js
More file actions
70 lines (64 loc) · 1.7 KB
/
Copy pathwdio.conf.js
File metadata and controls
70 lines (64 loc) · 1.7 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
import { setTimeout as sleep } from "node:timers/promises";
import { SevereServiceError } from "webdriverio";
const FRED_PORT = process.env.FRED_PORT || "3000";
const baseUrl = `http://localhost:${FRED_PORT}/`;
const READY_TIMEOUT = 60_000;
const READY_INTERVAL = 1000;
const READY_URL = `${baseUrl}en-US/docs/MDN/Kitchensink`;
const windowsCI = process.env.CI && process.platform === "win32";
/** @type {WebdriverIO.Config} */
export const config = {
runner: "local",
specs: ["./test/specs/**/*.js"],
maxInstances: 10,
specFileRetries: windowsCI ? 1 : 0,
capabilities: [
{
browserName: "firefox",
browserVersion: "stable",
"moz:firefoxOptions": {
args: ["-headless"],
},
},
],
services: [
[
"firefox-profile",
{
// Give the test framework permissions to read the clipboard:
"dom.events.testing.asyncClipboard": true,
"dom.events.testing.asyncClipboard.readText": true,
},
],
],
logLevel: "error",
framework: "mocha",
reporters: ["spec"],
mochaOpts: {
ui: "bdd",
timeout: 120_000,
},
baseUrl,
async onPrepare() {
console.log("waiting for servers to start");
const deadline = Date.now() + READY_TIMEOUT;
while (Date.now() < deadline) {
try {
const res = await fetch(READY_URL, {
signal: AbortSignal.timeout(deadline - Date.now()),
});
await res.text();
if (res.ok) {
return;
}
} catch {
// no-op
}
await sleep(READY_INTERVAL);
}
// wdio ignores anything but a SevereServiceError
throw new SevereServiceError(
`server not ready after ${READY_TIMEOUT}ms: ${READY_URL}`,
);
},
};