Skip to content

Commit

Permalink
Merge pull request #750 from step2yeung/browserIdNotFoundFix
Browse files Browse the repository at this point in the history
Ember exam failing when browser ID not found, return 0
  • Loading branch information
step2yeung authored Oct 28, 2021
2 parents 3a0fa31 + 7b1df6f commit b62bed3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
36 changes: 17 additions & 19 deletions lib/commands/exam.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,26 +292,24 @@ module.exports = TestCommand.extend({
const browserExitHandler = function (failed = false) {
const launcherId = this.launcher.id;
if (!failed && commands.get('loadBalance')) {
try {
const browserId = getBrowserId(this.launcher);
log.info(
`Browser ${browserId} exiting. [ # of modules in current module queue ${
testemEvents.stateManager.getTestModuleQueue().length
} ]`
);
} catch (err) {
const moduleQueueMessage =
testemEvents.stateManager.getTestModuleQueue() === null
? 'testModuleQueue is not set.'
: `[ # of modules in current module queue ${
testemEvents.stateManager.getTestModuleQueue().length
} ]`;

if (typeof err === 'object' && err !== null) {
err.message = `${err.message} \n ${moduleQueueMessage}`;
ui.writeLine(err.message);
const browserId = getBrowserId(this.launcher);
log.info(
`Browser ${browserId} exiting. [ # of modules in current module queue ${
testemEvents.stateManager.getTestModuleQueue().length
} ]`
);
// if getBrowserId cannot get the browserId
// but the test queue is not empty, report the number of test modules left in the queue
// otherwise, fail because testModuleQueue was not set
if (browserId === 0) {
if (testemEvents.stateManager.getTestModuleQueue() !== null) {
ui.writeLine(
`[ # of modules in current module queue ${
testemEvents.stateManager.getTestModuleQueue().length
} ]`
);
} else {
throw new Error(moduleQueueMessage);
throw new Error('testModuleQueue is not set.');
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/test-page-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ function getBrowserId(launcher) {
const errMsg = `${err.message} \n${
err.stack
} \nLauncher Settings: ${JSON.stringify(launcher.settings, null, 2)}`;
throw new Error(errMsg);
console.warn(errMsg);
}
return 0;
}

/**
Expand Down

0 comments on commit b62bed3

Please sign in to comment.