diff --git a/lib/index.js b/lib/index.js index 8190aa3e68..50e210690c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -85,6 +85,8 @@ Nightwatch.prototype.setOptions = function(options) { if (typeof screenshots.path == 'undefined') { throw new Error('Please specify the screenshots.path in nightwatch.json.'); } + this.options.screenshots.on_error = this.options.screenshots.on_error || + (typeof this.options.screenshots.on_error == 'undefined'); this.api.screenshotsPath = this.api.options.screenshotsPath = screenshots.path; } else { this.options.screenshots = { @@ -333,7 +335,7 @@ Nightwatch.prototype.runProtocolAction = function(requestOptions, callback) { }) .on('error', function(result, response, screenshotContent) { result = self.handleTestError(result); - if (screenshotContent && self.options.screenshots.enabled) { + if (screenshotContent && self.options.screenshots.on_error) { var fileNamePath = Utils.getScreenshotFileName('ERROR_', self.options.screenshots.path); self.saveScreenshotToFile(fileNamePath, screenshotContent); result.lastScreenshotFile = fileNamePath; diff --git a/lib/runner/cli/clirunner.js b/lib/runner/cli/clirunner.js index 130dfe46c4..768415ee64 100644 --- a/lib/runner/cli/clirunner.js +++ b/lib/runner/cli/clirunner.js @@ -426,6 +426,8 @@ CliRunner.prototype = { if (typeof this.test_settings.test_workers != 'undefined') { this.settings.test_workers = this.test_settings.test_workers; + } else if (typeof this.settings.test_workers != 'undefined') { + this.test_settings.test_workers = this.settings.test_workers; } if (typeof this.argv.skipgroup == 'string') { @@ -576,7 +578,6 @@ CliRunner.prototype = { this.startSelenium(function() { self.startChildProcesses(envs, function(code) { - self.stopSelenium().then(function() { if (self.parallelModeWorkers()) { return self.runGlobalAfter(); @@ -697,10 +698,11 @@ CliRunner.prototype = { self.childProcessOutput[filename] = []; - var childArgs = args.slice(); + var childArgs = []; childArgs.push('--test', modulePath, '--test-worker'); var child = new ChildProcess(filename, index, self.childProcessOutput[filename], self.settings, childArgs); child.setLabel(Utils.getModuleKey(modulePath, self.settings.src_folders, modulePaths)); + self.runningProcesses[child.itemKey] = child; self.runningProcesses[child.itemKey].run(availColors, function (output, exitCode) { if (exitCode > 0) { diff --git a/tests/src/index/testNightwatchIndex.js b/tests/src/index/testNightwatchIndex.js index 3da372e19f..a23173c191 100644 --- a/tests/src/index/testNightwatchIndex.js +++ b/tests/src/index/testNightwatchIndex.js @@ -172,6 +172,7 @@ module.exports = { eq(client.api.launch_url, '/home'); eq(client.options.screenshots.enabled, false); + eq(typeof client.options.screenshots.on_error, 'undefined'); eq(client.api.options.screenshots, false); test.done(); }, @@ -200,11 +201,28 @@ module.exports = { var eq = test.equals; eq(client.api.options.log_screenshot_data, true); + eq(client.options.screenshots.on_error, true); eq(client.api.options.screenshotsPath, ''); test.done(); }, + testSetOptionsScreenshotsOnError : function(test) { + var client = this.client = Client.init({ + screenshots : { + enabled : true, + on_error : true, + path : '' + }, + log_screenshot_data : true + }); + var eq = test.equals; + + eq(client.options.screenshots.on_error, true); + + test.done(); + }, + testSetOptionsScreenshotsThrows : function(test) { test.throws(function() { this.client = Client.init({ diff --git a/tests/src/runner/testParallelExecution.js b/tests/src/runner/testParallelExecution.js index 90d0d42a47..f672b814f6 100644 --- a/tests/src/runner/testParallelExecution.js +++ b/tests/src/runner/testParallelExecution.js @@ -151,6 +151,10 @@ module.exports = { enabled : true, workers : 'auto' }); + test.deepEqual(runner.test_settings.test_workers, { + enabled : true, + workers : 'auto' + }); test.ok(runner.parallelModeWorkers()); },