☕️ Classic, reliable, trusted test framework for Node.js and the browser
resolves #1072: do not expect uncaught exception to be an object
Christopher Hiller8de3bc8c4d40
diff --git a/lib/runner.js b/lib/runner.jsindex 61fc27aa..31196626 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -533,12 +533,14 @@ Runner.prototype.runSuite = function(suite, fn){Runner.prototype.uncaught = function(err){if (err) {- debug('uncaught exception %s', err.message);+ debug('uncaught exception %s', err !== function () {+ return this;+ }.call(err) ? err : ( err.message || err ));} else {debug('uncaught undefined exception');err = new Error('Catched undefined error, did you throw without specifying what?');}-+var runnable = this.currentRunnable;if (!runnable || 'failed' == runnable.state) return;runnable.clearTimeout();diff --git a/mocha.js b/mocha.jsindex 2135a955..107d5f99 100644--- a/mocha.js+++ b/mocha.js@@ -4963,12 +4963,14 @@ Runner.prototype.runSuite = function(suite, fn){Runner.prototype.uncaught = function(err){if (err) {- debug('uncaught exception %s', err.message);+ debug('uncaught exception %s', err !== function () {+ return this;+ }.call(err) ? err : ( err.message || err ));} else {debug('uncaught undefined exception');err = new Error('Catched undefined error, did you throw without specifying what?');}-+var runnable = this.currentRunnable;if (!runnable || 'failed' == runnable.state) return;runnable.clearTimeout();diff --git a/test/runnable.js b/test/runnable.jsindex ee20c8a5..6127b4ea 100644--- a/test/runnable.js+++ b/test/runnable.js@@ -225,6 +225,20 @@ describe('Runnable(title, fn)', function(){done();});})++ it('should not throw its own exception if passed a non-object', function (done) {+ var test = new Runnable('foo', function(done) {+ throw null;+ process.nextTick(done);+ });++ test.run(function(err) {+ if (err !== null) {+ throw new should.AssertionError('err should be null');+ }+ done();+ })+ });})describe('when an error is passed', function(){