-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathend-to-end-test-runner.js
39 lines (34 loc) · 1.18 KB
/
end-to-end-test-runner.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
#!/usr/bin/env node
// Taken from:
// https://github.com/browserstack/nightwatch-browserstack/blob/master/scripts/local.runner.js
var Nightwatch = require('nightwatch');
var browserstack = require('browserstack-local');
var bs_local;
try {
process.mainModule.filename = './node_modules/.bin/nightwatch';
// Code to start browserstack local before start of test
console.log('Connecting local');
Nightwatch.bs_local = bs_local = new browserstack.Local();
bs_local.start(
{ key: process.env.BROWSERSTACK_ACCESS_KEY },
function (error) {
if (error) throw error;
console.log('Connected. Now testing...');
Nightwatch.cli(function (argv) {
Nightwatch.CliRunner(argv)
.setup(null, function () {
// Code to stop browserstack local after end of parallel test
bs_local.stop(function () {});
})
.runTests(function () {
// Code to stop browserstack local after end of single test
bs_local.stop(function () {});
});
});
}
);
} catch (ex) {
console.log('There was an error while starting the test runner:\n\n');
process.stderr.write(ex.stack + '\n');
process.exit(2);
}