Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Add instanceof check for inheriting from Error

Greg Perkins8eedaab6d9e0
diff --git a/lib/runnable.js b/lib/runnable.js
index 79318cc3..c2406f75 100644
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -194,7 +194,7 @@ Runnable.prototype.run = function(fn){
if (this.async) {
try {
this.fn.call(ctx, function(err){
- if (toString.call(err) === "[object Error]") return done(err);
+ if (err instanceof Error || toString.call(err) === "[object Error]") return done(err);
if (null != err) return done(new Error('done() invoked with non-Error: ' + err));
done();
});