Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
chore(exitCodes): browser error for debug with multiple capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
cnishina committed May 17, 2016
1 parent 78279f7 commit 0dc0b26
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
2 changes: 2 additions & 0 deletions lib/exitCodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class ConfigError extends ProtractorError {
static CODE = CONFIG_ERROR_CODE;
constructor(logger: Logger, opt_msg?: string) {
super(logger, opt_msg || ConfigError.DEFAULT_MSG, ConfigError.CODE);
process.exit(ConfigError.CODE);
}
}

Expand All @@ -49,6 +50,7 @@ export class BrowserError extends ProtractorError {
];
constructor(logger: Logger, opt_msg?: string) {
super(logger, opt_msg || BrowserError.DEFAULT_MSG, BrowserError.CODE);
process.exit(BrowserError.CODE);
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
import * as q from 'q';
import {Config, ConfigParser} from './configParser';
import {ErrorHandler} from './exitCodes';
import {ConfigError, ErrorHandler} from './exitCodes';
import {Logger} from './logger2';
import {Runner} from './runner';
import {TaskRunner} from './taskRunner';
Expand Down Expand Up @@ -188,6 +188,7 @@ let initFn = function(configFile: string, additionalConfig: Config) {
});

process.on('exit', (code: number) => {
console.log(code);
if (code) {
logger.error('Process exited with error code ' + code);
} else if (scheduler.numTasksOutstanding() > 0) {
Expand Down Expand Up @@ -223,9 +224,8 @@ let initFn = function(configFile: string, additionalConfig: Config) {
1) { // Start new processes only if there are >1 tasks.
forkProcess = true;
if (config.debug) {
throw new Error(
'Cannot run in debug mode with ' +
'multiCapabilities, count > 1, or sharding');
throw new ConfigError(logger,
'Cannot run in debug mode with multiCapabilities, count > 1, or sharding');
}
}

Expand Down
30 changes: 21 additions & 9 deletions scripts/exitCodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
'use strict';

var spawn = require('child_process').spawnSync;
var exitCodes = require('../built/exitCodes');

var runProtractor, output, messages;
var checkLogs = function(output, messages) {
for (var pos in messages) {
Expand All @@ -17,18 +19,28 @@ var checkLogs = function(output, messages) {
*Below are exit failure tests*
******************************/

// // assert authentication error for sauce labs
// runProtractor = spawn('node',
// ['bin/protractor', 'spec/errorTest/sauceLabsAuthentication.js']);
// output = runProtractor.stdout.toString();
// messages = ['WebDriverError: Sauce Labs Authentication Error.',
// 'Process exited with error code 135'];
// checkLogs(output, messages);

// assert authentication error for sauce labs
runProtractor = spawn('node',
['bin/protractor', 'spec/errorTest/sauceLabsAuthentication.js']);
output = runProtractor.stdout.toString();
messages = ['WebDriverError: Sauce Labs Authentication Error.',
'Process exited with error code ' + exitCodes.BrowserError.CODE];
checkLogs(output, messages);

// assert authentication error for browser stack
runProtractor = spawn('node',
['bin/protractor', 'spec/errorTest/browserStackAuthentication.js']);
output = runProtractor.stdout.toString();
messages = ['WebDriverError: Invalid username or password',
'Process exited with error code 135'];
'Process exited with error code ' + exitCodes.BrowserError.CODE];
checkLogs(output, messages);


// assert there is no capabilities in the config
runProtractor = spawn('node',
['bin/protractor', 'spec/errorTest/debugMultiCapabilities.js']);
output = runProtractor.stdout.toString();
messages = [
'Cannot run in debug mode with multiCapabilities, count > 1, or sharding',
'Process exited with error code ' + exitCodes.ConfigError.CODE];
checkLogs(output, messages);
16 changes: 16 additions & 0 deletions spec/errorTest/debugMultiCapabilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var env = require('../environment.js');

exports.config = {
seleniumAddress: env.seleniumAddress,
framework: 'jasmine',
debug: true,
specs: [
'../../example/example_spec.js'
],
multiCapabilities: [{
'browserName': 'chrome'
},{
'browserName': 'firefox'
}],
baseUrl: env.baseUrl,
};

0 comments on commit 0dc0b26

Please sign in to comment.