diff --git a/test/integration/options/failZero.spec.js b/test/integration/options/failZero.spec.js new file mode 100644 index 0000000000..02b88c40c2 --- /dev/null +++ b/test/integration/options/failZero.spec.js @@ -0,0 +1,22 @@ +'use strict'; + +var helpers = require('../helpers'); +var runMochaJSON = helpers.runMochaJSON; + +describe('--fail-zero', function() { + var args = ['--fail-zero', '--grep', 'yyyyyy']; + + it('should fail since no tests are encountered', function(done) { + var fixture = '__default__.fixture.js'; + runMochaJSON(fixture, args, function(err, res) { + if (err) { + return done(err); + } + + expect(res, 'to have passed test count', 0) + .and('to have test count', 0) + .and('to have exit code', 1); + done(); + }); + }); +}); diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js index 35f7abd327..6255e2ad9f 100644 --- a/test/unit/mocha.spec.js +++ b/test/unit/mocha.spec.js @@ -265,22 +265,18 @@ describe('Mocha', function() { }); describe('bail()', function() { - describe('when provided no arguments', function() { - it('should set the "bail" flag on the root suite', function() { - mocha.bail(); - expect(suite.bail, 'to have a call satisfying', [true]).and( - 'was called once' - ); - }); + it('should set the "bail" flag on the root suite', function() { + mocha.bail(); + expect(suite.bail, 'to have a call satisfying', [true]).and( + 'was called once' + ); }); - describe('when provided a falsy argument', function() { - it('should unset the "bail" flag on the root suite', function() { - mocha.bail(false); - expect(suite.bail, 'to have a call satisfying', [false]).and( - 'was called once' - ); - }); + it('should unset the "bail" flag on the root suite', function() { + mocha.bail(false); + expect(suite.bail, 'to have a call satisfying', [false]).and( + 'was called once' + ); }); it('should be chainable', function() { @@ -344,25 +340,9 @@ describe('Mocha', function() { expect(mocha.options, 'to have property', 'diff', true); }); - describe('when provided `false` argument', function() { - it('should set the diff option to false', function() { - mocha.diff(false); - expect(mocha.options, 'to have property', 'diff', false); - }); - }); - }); - - describe('dryRun()', function() { - it('should set the dryRun option to true', function() { - mocha.dryRun(); - expect(mocha.options, 'to have property', 'dryRun', true); - }); - - describe('when provided `false` argument', function() { - it('should set the dryRun option to false', function() { - mocha.dryRun(false); - expect(mocha.options, 'to have property', 'dryRun', false); - }); + it('should set the diff option to false', function() { + mocha.diff(false); + expect(mocha.options, 'to have property', 'diff', false); }); }); @@ -385,6 +365,30 @@ describe('Mocha', function() { }); }); + describe('dryRun()', function() { + it('should set the dryRun option to true', function() { + mocha.dryRun(); + expect(mocha.options, 'to have property', 'dryRun', true); + }); + + it('should set the dryRun option to false', function() { + mocha.dryRun(false); + expect(mocha.options, 'to have property', 'dryRun', false); + }); + }); + + describe('failZero()', function() { + it('should set the failZero option to true', function() { + mocha.failZero(); + expect(mocha.options, 'to have property', 'failZero', true); + }); + + it('should set the failZero option to false', function() { + mocha.failZero(false); + expect(mocha.options, 'to have property', 'failZero', false); + }); + }); + describe('forbidOnly()', function() { it('should set the forbidOnly option to true', function() { mocha.forbidOnly();