Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Changed: fail when done() is invoked with a non-Error. Closes #171

Tj Holowaychuk08f29170ef94
diff --git a/lib/runnable.js b/lib/runnable.js
index 78b4fb67..d1512abd 100644
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -137,6 +137,7 @@ Runnable.prototype.run = function(fn){
try {
this.fn(function(err){
if (err instanceof Error) return done(err);
+ if (null != err) return done(new Error('done() invoked with non-Error: ' + err));
done();
});
} catch (err) {
diff --git a/test/runnable.js b/test/runnable.js
index 7a48fe32..ad31b749 100644
--- a/test/runnable.js
+++ b/test/runnable.js
@@ -91,14 +91,6 @@ describe('Runnable(title, fn)', function(){
})
})
- describe('when the callback is invoked with a non-Error', function(){
- it('should pass', function(done){
- var thing = new EventEmitter;
- thing.on('foo', done);
- thing.emit('foo', 'bar');
- })
- })
-
describe('when the callback is invoked several times', function(){
describe('without an error', function(){
it('should emit a single "error" event', function(done){