diff --git a/lib/runner.js b/lib/runner.js index 22e7bb91d6..6851ab281b 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -989,6 +989,7 @@ Runner.prototype.run = function(fn, opts) { fn = fn || function() {}; function start() { + self._addEventListener(process, 'uncaughtException', self.uncaught); debug('run(): starting'); // If there is an `only` filter if (rootSuite.hasOnly()) { @@ -1027,11 +1028,9 @@ Runner.prototype.run = function(fn, opts) { debug(constants.EVENT_RUN_END); debug('run(): emitted %s', constants.EVENT_RUN_END); fn(self.failures); + self._removeEventListener(process, 'uncaughtException', self.uncaught); }); - self._removeEventListener(process, 'uncaughtException', self.uncaught); - self._addEventListener(process, 'uncaughtException', self.uncaught); - if (this._delay) { // for reporters, I guess. // might be nice to debounce some dots while we wait.