☕️ Classic, reliable, trusted test framework for Node.js and the browser
fix uncaught error support for the browser
TJ Holowaychukeb58761bb334
diff --git a/mocha.js b/mocha.jsindex b14eb174..de329bdb 100644--- a/mocha.js+++ b/mocha.js@@ -4215,15 +4215,10 @@ Runner.prototype.run = function(fn){debug('start');- // uncaught callback- function uncaught(err, url, line) {- self.uncaught(new Error(err + ' (' + url + ':' + line + ')'));- }-// callbackthis.on('end', function(){debug('end');- process.removeListener('uncaughtException', uncaught);+ process.removeListener('uncaughtException', self.uncaught.bind(self));fn(self.failures);});@@ -4235,7 +4230,7 @@ Runner.prototype.run = function(fn){});// uncaught exception- process.on('uncaughtException', uncaught);+ process.on('uncaughtException', this.uncaught.bind(this));return this;};@@ -4946,7 +4941,9 @@ process.removeListener = function(e){process.on = function(e, fn){if ('uncaughtException' == e) {- window.onerror = fn;+ window.onerror = function(err, url, line){+ fn(new Error(err + ' (' + url + ':' + line + ')'));+ };}};diff --git a/support/tail.js b/support/tail.jsindex 9b7a533b..0f9b64a4 100644--- a/support/tail.js+++ b/support/tail.js@@ -56,7 +56,9 @@ process.removeListener = function(e){process.on = function(e, fn){if ('uncaughtException' == e) {- window.onerror = fn;+ window.onerror = function(err, url, line){+ fn(new Error(err + ' (' + url + ':' + line + ')'));+ };}};diff --git a/test/browser/large.js b/test/browser/large.jsindex 5137daa5..7974bb6f 100644--- a/test/browser/large.js+++ b/test/browser/large.js@@ -20,4 +20,13 @@ while (n--) {})})})-}\ No newline at end of file+}++describe('something', function(){+ it('should provide a useful error', function(done){+ setTimeout(function(){+ throw new Error('boom');+ done();+ }, 1);+ })+})\ No newline at end of file