Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions conf/local.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ var browserstack = require('browserstack-local');
nightwatch_config = {
src_folders : [ "tests/local" ],

proxy: {
"host": "",
"port": "",
"user": "",
"pass": ""
},

selenium : {
"start_process" : false,
"host" : "hub-cloud.browserstack.com",
Expand Down
41 changes: 39 additions & 2 deletions scripts/local.runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,52 @@

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");
console.log('Connecting local');
Nightwatch.bs_local = bs_local = new browserstack.Local();
bs_local.start({'key': process.env.BROWSERSTACK_ACCESS_KEY }, function(error) {

var localOptions = {
'key': process.env.BROWSERSTACK_ACCESS_KEY
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to use localConf for the key ? It is present in the test_settings .

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

};

/**
* 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...');
Expand Down