diff --git a/lib/commands/exam.js b/lib/commands/exam.js index 9a05b804c..0748056d6 100644 --- a/lib/commands/exam.js +++ b/lib/commands/exam.js @@ -309,23 +309,23 @@ module.exports = TestCommand.extend({ const launcherId = this.launcher.id; if (!failed && commands.get('loadBalance')) { const browserId = getBrowserId(this.launcher); - log.info( - `Browser ${browserId} exiting. [ # of modules in current module queue ${ - testemEvents.stateManager.getTestModuleQueue().length - } ]` - ); + const moduleQueue = testemEvents.stateManager.getTestModuleQueue(); + const noModuleQueue = 'testModuleQueue is not set.'; + const numQueues = + moduleQueue !== null + ? `[ # of modules in current module queue ${moduleQueue.length} ]` + : `[ ${noModuleQueue} ]`; + log.info(`Browser ${browserId} exiting. ${numQueues}`); // 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) { + if (moduleQueue !== null) { ui.writeLine( - `[ # of modules in current module queue ${ - testemEvents.stateManager.getTestModuleQueue().length - } ]` + `[ # of modules in current module queue ${moduleQueue.length} ]` ); } else { - throw new Error('testModuleQueue is not set.'); + throw new Error(noModuleQueue); } } }