Skip to content

Commit

Permalink
fixed a problem with disabling start_selenium per environment
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Aug 25, 2014
1 parent 57b3209 commit 03c05e7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
5 changes: 5 additions & 0 deletions bin/_clirunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ CliRunner.prototype = {
this.replaceEnvVariables();
this.manageSelenium = !this.isParallelMode() && this.settings.selenium &&
this.settings.selenium.start_process || false;

if (typeof this.settings.src_folders == 'string') {
this.settings.src_folders = [this.settings.src_folders];
}
Expand Down Expand Up @@ -332,9 +333,13 @@ CliRunner.prototype = {

// overwrite selenium settings per environment
if (this.test_settings.selenium && typeof (this.test_settings.selenium) == 'object') {
this.settings.selenium = this.settings.selenium || {};
for (var prop in this.test_settings.selenium) {
this.settings.selenium[prop] = this.test_settings.selenium[prop];
}
if (this.settings.selenium.start_process === false) {
this.manageSelenium = false;
}
}

this.mergeSeleniumOptions();
Expand Down
4 changes: 2 additions & 2 deletions lib/runner/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module.exports = new (function() {
onComplete(results, errors);
});
client.once('error', function(data, error) {
finishCallback({message: '\nConnection refused! Is selenium server started?', data : error}, false);
finishCallback({message: '\nConnection refused! Is selenium server started?\n', data : error}, false);
});
client.once('selenium:session_create', function() {
opts.report_prefix = this.api.capabilities.browserName.toUpperCase() +
Expand Down Expand Up @@ -252,7 +252,7 @@ module.exports = new (function() {
if (exitCode === 0 && (globalResults.errors > 0 || globalResults.failed > 0)) {
exitCode = 1;
}

process.exit(exitCode);
});

Expand Down
38 changes: 38 additions & 0 deletions tests/src/runner/testCliRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ module.exports = {
}
}
});
mockery.registerMock('./sauce.json', {
src_folders : 'tests',
selenium : {
start_process: true
},
test_settings : {
'default' : {
},
'saucelabs' : {
selenium : {
start_process : false
}
}
}
});
mockery.registerMock('./custom.json', {
src_folders : ['tests'],
selenium : {
Expand Down Expand Up @@ -118,6 +133,9 @@ module.exports = {
if (b == 'demoGroup') {
return 'tests/demoGroup';
}
if (b == './sauce.json') {
return './sauce.json';
}
return './nightwatch.json';
},
resolve : function(a) {
Expand Down Expand Up @@ -160,6 +178,7 @@ module.exports = {
page_objects_path: '',
output: true
}});

test.equals(runner.output_folder, 'output');
test.equals(runner.parallelMode, false);
test.equals(runner.manageSelenium, false);
Expand Down Expand Up @@ -412,6 +431,25 @@ module.exports = {
});
},

testStartSeleniumDisabledPerEnvironment : function(test) {
mockery.registerMock('fs', {
existsSync : function(module) {
if (module == './sauce.json') {
return true;
}
return false;
}
});
var CliRunner = require('../../../'+ BASE_PATH +'/../bin/_clirunner.js');
var runner = new CliRunner({
c : './sauce.json',
e : 'saucelabs'
}).init();

test.equal(runner.manageSelenium, false);
test.done();
},

testStartSeleniumEnabled : function(test) {
mockery.registerMock('../lib/runner/selenium.js', {
startServer : function(settings, cb) {
Expand Down

0 comments on commit 03c05e7

Please sign in to comment.