Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Fixed multiple-done() from taking precedence over errors

TJ Holowaychuk0e9d610efbac
diff --git a/lib/runnable.js b/lib/runnable.js
index 329e2857..835cca3a 100644
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -146,16 +146,16 @@ Runnable.prototype.run = function(fn){
}
// called multiple times
- function multiple() {
+ function multiple(err) {
if (emitted) return;
emitted = true;
- self.emit('error', new Error('done() called multiple times'));
+ self.emit('error', err || new Error('done() called multiple times'));
}
// finished
function done(err) {
if (self.timedOut) return;
- if (finished) return multiple();
+ if (finished) return multiple(err);
self.clearTimeout();
self.duration = new Date - start;
finished = true;