Skip to content

Commit

Permalink
Fixed: recover from uncaught exceptions for tests. Closes #94
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Dec 15, 2011
1 parent a14226f commit f83c4c7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,15 @@ Runner.prototype.runTests = function(suite, fn){
return self.hookUp('afterEach', next);
}

self.emit('pass', test);
test.passed = true;
self.emit('pass', test);
self.emit('test end', test);
self.hookUp('afterEach', next);
});
});
}

this.next = next;
next();
};

Expand Down Expand Up @@ -394,8 +395,15 @@ Runner.prototype.run = function(fn){
debug('uncaught exception');
runnable.clearTimeout();
self.fail(runnable, err);
if ('test' == runnable.type) self.emit('test end', runnable);
self.emit('end');

// recover from test
if ('test' == runnable.type) {
self.emit('test end', runnable);
self.hookUp('afterEach', self.next);
// bail on hooks
} else {
self.emit('end');
}
}

process.on('uncaughtException', uncaught);
Expand Down

0 comments on commit f83c4c7

Please sign in to comment.