Skip to content

Commit 408b8cc

Browse files
Removed additional config file
Removed additional config file
1 parent 859738e commit 408b8cc

File tree

5 files changed

+24
-126
lines changed

5 files changed

+24
-126
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
playwright-report
33
local.log
4+
local.log

global-setup.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,24 @@ const sleep = promisify(setTimeout);
55
const redColour = "\x1b[31m";
66
const whiteColour = "\x1b[0m";
77
module.exports = async () => {
8-
console.log("Starting BrowserStackLocal ...");
9-
// Starts the Local instance with the required arguments
10-
let localResponseReceived = false;
11-
bsLocal.start(BS_LOCAL_ARGS, (err) => {
12-
if (err) {
13-
console.error(
14-
`${redColour}Error starting BrowserStackLocal${whiteColour}`
15-
);
16-
} else {
17-
console.log("BrowserStackLocal Started");
8+
if (process.env.BROWSERSTACK_LOCAL === "true") {
9+
console.log("Starting BrowserStackLocal ...");
10+
// Starts the Local instance with the required arguments
11+
let localResponseReceived = false;
12+
bsLocal.start(BS_LOCAL_ARGS, (err) => {
13+
if (err) {
14+
console.error(
15+
`${redColour}Error starting BrowserStackLocal${whiteColour}`
16+
);
17+
} else {
18+
console.log("BrowserStackLocal Started");
19+
}
20+
localResponseReceived = true;
21+
});
22+
while (!localResponseReceived) {
23+
await sleep(1000);
1824
}
19-
localResponseReceived = true;
20-
});
21-
while (!localResponseReceived) {
22-
await sleep(1000);
25+
} else {
26+
console.log("Skipping BrowserStackLocal...");
2327
}
2428
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"sample-local-test": "BROWSERSTACK_LOCAL=true npx playwright test tests/local_test.js --config=./playwright-local.config.js",
7+
"sample-local-test": "BROWSERSTACK_LOCAL=true npx playwright test tests/local_test.js",
88
"sample-test": "npx playwright test tests/sample_test.js",
99
"mobile-test": "npx playwright test tests/sample_test.js --project='chrome@Samsung Galaxy S22:13@browserstack'"
1010
},

playwright-local.config.js

Lines changed: 0 additions & 111 deletions
This file was deleted.

playwright.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const config = {
1616
testDir: "./tests",
1717
testMatch: "**/*.js",
1818

19+
// Use globalSetup & globalTearedown only if browserstack.local = true
20+
globalSetup: require.resolve("./global-setup"),
21+
globalTeardown: require.resolve("./global-teardown"),
22+
1923
/* Maximum time one test can run for. */
2024
timeout: 90 * 1000,
2125
expect: {

0 commit comments

Comments
 (0)