Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

more of last commit :)

Tj Holowaychukd37af5323c53
diff --git a/lib/runner.js b/lib/runner.js
index 2a5f158e..a63b9895 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -166,13 +166,20 @@ Runner.prototype.runTest = function(fn){
, self = this;
// async
- if (test.async) return test.run(function(err){
- if (test.finished) {
- self.fail(test, new Error('done() called multiple times'));
- return;
+ if (test.async) {
+ try {
+ return test.run(function(err){
+ if (test.finished) {
+ self.fail(test, new Error('done() called multiple times'));
+ return;
+ }
+ fn(err);
+ });
+ } catch (err) {
+ fn(err);
}
- fn(err);
- });
+ }
+
// sync
process.nextTick(function(){
try {