-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathlocal.runner.js
executable file
·70 lines (56 loc) · 1.81 KB
/
local.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
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
#!/usr/bin/env node
var Nightwatch = require('nightwatch');
var browserstack = require('browserstack-local');
var localConf = require('../conf/local.conf.js');
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();
var localOptions = {
'key': localConf['test_settings']['default']['desiredCapabilities']['browserstack.key']
};
/**
* If the network requires proxy configuration for outbound connections,
* set those here.
*/
var proxySettings = localConf['proxy'] || {};
for (var key in proxySettings) {
var value = proxySettings[key];
switch (key) {
case 'host':
if (value) localOptions['proxyHost'] = value;
break;
case 'port':
if (value) localOptions['proxyPort'] = value;
break;
case 'user':
if (value) localOptions['proxyUser'] = value;
break;
case 'pass':
if (value) localOptions['proxyPass'] = value;
break;
}
}
console.log('Local options: \n', localOptions);
bs_local.start(localOptions, 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);
}