diff --git a/test/unit/runner.spec.js b/test/unit/runner.spec.js index bca784ae90..86779d6594 100644 --- a/test/unit/runner.spec.js +++ b/test/unit/runner.spec.js @@ -3,6 +3,7 @@ var path = require('path'); var sinon = require('sinon'); var Mocha = require('../../lib/mocha'); +var Pending = require('../../lib/pending'); var Suite = Mocha.Suite; var Runner = Mocha.Runner; var Test = Mocha.Test; @@ -690,6 +691,20 @@ describe('Runner', function() { sandbox.stub(runner, 'fail'); }); + describe('when allow-uncaught is set to true', function() { + it('should propagate error and throw', function() { + var err = new Error('should rethrow err'); + runner.allowUncaught = true; + expect( + function() { + runner.uncaught(err); + }, + 'to throw', + 'should rethrow err' + ); + }); + }); + describe('when provided an object argument', function() { describe('when argument is not an Error', function() { var err; @@ -713,6 +728,13 @@ describe('Runner', function() { }); }); + describe('when argument is a Pending', function() { + it('should ignore argument and return', function() { + var err = new Pending(); + expect(runner.uncaught(err), 'to equal', undefined); + }); + }); + describe('when argument is an Error', function() { var err; beforeEach(function() {