☕️ Classic, reliable, trusted test framework for Node.js and the browser
Added `Runner#fail(test, err)`
Tj Holowaychuk14923280a9b1
diff --git a/lib/runner.js b/lib/runner.jsindex 9ed61736..20f64f19 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -39,6 +39,19 @@ function Runner(suite) {Runner.prototype.__proto__ = EventEmitter.prototype;+/**+ * Fail the given `test`.+ *+ * @param {Test} test+ * @param {Error} err+ * @api private+ */++Runner.prototype.fail = function(test, err){+ test.failed = true;+ this.emit('fail', test, err);+};+/*** Run hook `name` callbacks and then invoke `fn(err)`.*@@ -123,8 +136,7 @@ Runner.prototype.runTests = function(suite, fn){// error handlingif (err) {if (!test) throw err;- test.failed = true;- self.emit('fail', test, err);+ self.fail(test, err);}// next test@@ -195,8 +207,7 @@ Runner.prototype.run = function(){// uncaught exceptionprocess.on('uncaughtException', function(err){- self.test.failed = true;- self.emit('fail', self.test, err);+ self.fail(self.test, err);self.emit('end');});diff --git a/test/unit/uncaught.js b/test/unit/uncaught.jsindex e1964da7..86ef8b7a 100644--- a/test/unit/uncaught.js+++ b/test/unit/uncaught.js@@ -1,5 +1,9 @@describe('uncaught', function(){+ before(function(){+ throw new Error('test')+ })+it('should report properly', function(done){process.nextTick(function(){// if you uncomment this :)