Skip to content

Commit

Permalink
Add test on failOnFailingTestSuite
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgonmic committed Oct 18, 2021
1 parent eaf9283 commit 5c1be0d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/integration/fixtures/require-undefined.fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// this generic fixture does nothing special and will be used if no fixture is supplied

'use strict';

var assert = require('assert');

describe('a suite', function() {
it('should succeed', function() {
assert(false);
});
});
22 changes: 22 additions & 0 deletions test/integration/options/failOnFailingTestSuite.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

var helpers = require('../helpers');
var runMochaJSON = helpers.runMochaJSON;

describe('--fail-on-failing-test-suite', function() {
var args = ['--fail-on-failing-test-suite=false'];

it('should success', function(done) {
var fixture = 'require-undefined.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', 1)
.and('to have exit code', 0);
done();
});
});
});
22 changes: 22 additions & 0 deletions test/unit/mocha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,28 @@ describe('Mocha', function() {
});
});

describe('failOnFailingTestSuite()', function() {
it('should set the failOnFailingTestSuite option to true', function() {
mocha.failOnFailingTestSuite();
expect(
mocha.options,
'to have property',
'failOnFailingTestSuite',
true
);
});

it('should set the failOnFailingTestSuite option to false', function() {
mocha.failOnFailingTestSuite(false);
expect(
mocha.options,
'to have property',
'failOnFailingTestSuite',
false
);
});
});

describe('failZero()', function() {
it('should set the failZero option to true', function() {
mocha.failZero();
Expand Down

0 comments on commit 5c1be0d

Please sign in to comment.