-
Notifications
You must be signed in to change notification settings - Fork 25
/
wdio.conf.js
144 lines (132 loc) · 3.17 KB
/
wdio.conf.js
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
const uuid = require("uuid").v4;
const browserstack = require("browserstack-local");
// Stop node from complaining about fake memory leaks at higher concurrency
require("events").defaultMaxListeners = 20;
require("dotenv").config();
const ONLY_BROWSERS = process.env.ONLY_BROWSERS;
const localIdentifier = uuid();
const projectName = "Restricted Input";
let type;
if (!process.env.GITHUB_REF) {
type = "Local";
} else {
type = "CI";
}
const build = `${projectName} - ${type} ${Date.now()}`;
const desktopCapabilities = {
"bstack:options": {
os: "Windows",
osVersion: "10",
local: "true",
debug: "true",
seleniumVersion: "3.14.0",
localIdentifier,
},
browserVersion: "latest",
};
let capabilities = [
{
...desktopCapabilities,
browserName: "Chrome",
},
{
...desktopCapabilities,
browserName: "Edge",
},
{
...desktopCapabilities,
browserName: "Firefox",
},
// TODO safari doesn't work on github actions
// {
// ...desktopCapabilities,
// browserName: "Desktop Safari",
// browser: "safari",
// os: "OS X",
// os_version: "Mojave",
// },
];
if (ONLY_BROWSERS) {
capabilities = ONLY_BROWSERS.split(",").map((browser) =>
capabilities.find(
(config) => config.browserName.toLowerCase() === browser.toLowerCase()
)
);
if (capabilities.length === 0) {
throw new Error(`Could not find browsers ${ONLY_BROWSERS} in config`);
}
}
const mochaOpts = {
timeout: 90000,
};
if (!process.env.DISABLE_RETRIES) {
mochaOpts.retries = 3;
}
exports.config = {
user: process.env.BROWSERSTACK_USERNAME,
key: process.env.BROWSERSTACK_ACCESS_KEY,
specs: require("fs")
.readdirSync("./test/integration")
.map((f) => `./test/integration/${f}`),
maxInstances: 4,
capabilities,
sync: true,
logLevel: "error",
deprecationWarnings: true,
bail: 0,
waitforTimeout: 20000,
connectionRetryTimeout: 90000,
connectionRetryCount: 1,
services: [
[
"browserstack",
{
runner: "local",
browserstackLocal: true,
},
],
],
framework: "mocha",
mochaOpts,
reporters: ["spec"],
reportOptions: {
outputDir: "./",
},
onPrepare() {
/* eslint-disable no-console */
console.log("Connecting local");
return new Promise((resolve, reject) => {
exports.bs_local = new browserstack.Local();
exports.bs_local.start(
{
key: process.env.BROWSERSTACK_ACCESS_KEY,
localIdentifier,
},
(error) => {
if (error) return reject(error);
console.log(`Connected with localIdentifier=${localIdentifier}`);
console.log(
"Testing in the following browsers:",
capabilities
.map(
(browser) => `${browser.browserName}@${browser.browserVersion}`
)
.join(", ")
);
return resolve();
}
);
});
/* eslint-enable no-console */
},
before(capabilities) {
// Mobile devices/selenium don't support the following APIs yet
browser.setTimeout({
pageLoad: 10000,
script: 5 * 60 * 1000,
});
},
onComplete() {
exports.bs_local.stop(() => {});
},
};