Skip to content

Commit

Permalink
fix(executor): ensure run_complete is emitted last
Browse files Browse the repository at this point in the history
Fixes #2210
  • Loading branch information
dignifiedquire committed Jun 30, 2016
1 parent 9b7cb64 commit 9c894f9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/executor.js
Expand Up @@ -17,6 +17,7 @@ var Executor = function (capturedBrowsers, config, emitter) {

if (capturedBrowsers.areAllReady(nonReady)) {
log.debug('All browsers are ready, executing')
log.debug('Captured %s browsers', capturedBrowsers.length)
executionScheduled = false
capturedBrowsers.clearResults()
capturedBrowsers.setAllToExecuting()
Expand Down Expand Up @@ -44,7 +45,11 @@ var Executor = function (capturedBrowsers, config, emitter) {
pendingCount--

if (!pendingCount) {
emitter.emit('run_complete', runningBrowsers, runningBrowsers.getResults())
// Ensure run_complete is emitted in the next tick
// so it is never emitted before browser_complete
setTimeout(function () {
emitter.emit('run_complete', runningBrowsers, runningBrowsers.getResults())
}, 0)
}
}

Expand Down

0 comments on commit 9c894f9

Please sign in to comment.