forked from browserstack/node-js-playwright-browserstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global-setup.js
28 lines (28 loc) · 865 Bytes
/
global-setup.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
// global-setup.js
const { bsLocal, BS_LOCAL_ARGS } = require("./fixture");
const { promisify } = require("util");
const sleep = promisify(setTimeout);
const redColour = "\x1b[31m";
const whiteColour = "\x1b[0m";
module.exports = async () => {
if (process.env.BROWSERSTACK_LOCAL === "true") {
console.log("Starting BrowserStackLocal ...");
// Starts the Local instance with the required arguments
let localResponseReceived = false;
bsLocal.start(BS_LOCAL_ARGS, (err) => {
if (err) {
console.error(
`${redColour}Error starting BrowserStackLocal${whiteColour}`
);
} else {
console.log("BrowserStackLocal Started");
}
localResponseReceived = true;
});
while (!localResponseReceived) {
await sleep(1000);
}
} else {
console.log("Skipping BrowserStackLocal...");
}
};