Skip to content

Commit 09db7ae

Browse files
committed
updated local test
1 parent 8f085b0 commit 09db7ae

File tree

5 files changed

+66
-68
lines changed

5 files changed

+66
-68
lines changed

local_globals.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var browserstack = require('browserstack-local');
2+
var bs_local;
3+
4+
module.exports = {
5+
before : function(done) {
6+
console.log("Connecting local");
7+
bs_local = new browserstack.Local();
8+
bs_local.start({'key': browser.options.desiredCapabilities['browserstack.key'] }, function(error) {
9+
if (error) return done(error);
10+
11+
console.log('Connected. Now testing...');
12+
done();
13+
});
14+
},
15+
16+
after : function(done) {
17+
bs_local.stop(done);
18+
}
19+
}

nightwatch_local.conf.js

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,58 @@
1+
var browserstack = require('browserstack-local');
2+
13
nightwatch_config = {
2-
src_folders : [ "tests/" ],
4+
src_folders : [ "tests/local" ],
35

46
selenium : {
57
"start_process" : false,
68
"host" : "hub-cloud.browserstack.com",
79
"port" : 80
810
},
911

12+
common_capabilities: {
13+
'build': 'nightwatch-browserstack',
14+
'browserstack.user': process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
15+
'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
16+
'browserstack.debug': true,
17+
"browserstack.local": true
18+
},
19+
1020
test_settings: {
11-
default: {
12-
selenium_host : "hub.browserstack.com",
13-
selenium_port : 80,
14-
silent: true,
21+
default: {},
22+
chrome: {
1523
desiredCapabilities: {
16-
build: "Sample tests for Nightwatch",
17-
"browserstack.user": process.env.BROWSERSTACK_USERNAME,
18-
"browserstack.key": process.env.BROWSERSTACK_ACCESS_KEY,
19-
"browserstack.debug": true,
20-
"browserstack.local": true
24+
browser: "chrome"
2125
}
2226
},
23-
chrome_48: {
24-
selenium_host : "hub.browserstack.com",
25-
selenium_port : 80,
26-
silent: true,
27+
firefox: {
2728
desiredCapabilities: {
28-
build: "Sample tests for Nightwatch",
29-
"browserstack.user": process.env.BROWSERSTACK_USERNAME,
30-
"browserstack.key": process.env.BROWSERSTACK_ACCESS_KEY,
31-
"browserstack.debug": true,
32-
33-
browser: "chrome",
34-
browser_verion: "48",
35-
os: "Windows",
36-
os_version: "10",
37-
"browserstack.local": true
29+
browser: "firefox"
3830
}
3931
},
40-
firefox_45: {
41-
selenium_host : "hub.browserstack.com",
42-
selenium_port : 80,
43-
silent: true,
32+
safari: {
4433
desiredCapabilities: {
45-
build: "Sample tests for Nightwatch",
46-
"browserstack.user": process.env.BROWSERSTACK_USERNAME,
47-
"browserstack.key": process.env.BROWSERSTACK_ACCESS_KEY,
48-
"browserstack.debug": true,
49-
50-
browser: "firefox",
51-
browser_verion: "45",
52-
os: "OS X",
53-
os_version: "El Capitan",
54-
"browserstack.local": true
34+
browser: "safari"
35+
}
36+
},
37+
ie: {
38+
desiredCapabilities: {
39+
browser: "internet explorer"
5540
}
5641
}
57-
}
42+
},
43+
44+
globals_path: 'local_globals.js'
5845
};
5946

47+
// Code to support common capabilites
48+
for(var i in nightwatch_config.test_settings){
49+
var config = nightwatch_config.test_settings[i];
50+
config['selenium_host'] = nightwatch_config.selenium.host;
51+
config['selenium_port'] = nightwatch_config.selenium.port;
52+
config['desiredCapabilities'] = config['desiredCapabilities'] || {};
53+
for(var j in nightwatch_config.common_capabilities){
54+
config['desiredCapabilities'][j] = config['desiredCapabilities'][j] || nightwatch_config.common_capabilities[j];
55+
}
56+
}
57+
6058
module.exports = nightwatch_config;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"test": "./node_modules/.bin/nightwatch",
88
"single": "./node_modules/.bin/nightwatch",
9-
"local": "node scripts/test_local.js",
9+
"local": "./node_modules/.bin/nightwatch -c nightwatch_local.conf.js",
1010
"parallel": "./node_modules/.bin/nightwatch -e chrome,firefox,safari,ie"
1111
},
1212
"repository": {

scripts/test_local.js

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

tests/local/local_test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
'BrowserStack Local Testing' : function (browser) {
3+
browser
4+
.url('http://bs-local.com:45691/check')
5+
.waitForElementVisible('body', 1000)
6+
.assert.containsText('body', 'Up and running')
7+
.end();
8+
}
9+
};

0 commit comments

Comments
 (0)