diff --git a/test/assertions.js b/test/assertions.js index a187d8a5be..b6468eb900 100644 --- a/test/assertions.js +++ b/test/assertions.js @@ -41,7 +41,7 @@ exports.mixinMochaAssertions = function (expect) { }); }) .addAssertion(' [not] to have passed', function (expect, result) { - expect(result.code, '[not] to have completed with code', 0); + expect(result.code, '[not] to be', 0); }) .addAssertion( ' [not] to have completed with [exit] code ', @@ -77,6 +77,9 @@ exports.mixinMochaAssertions = function (expect) { failures: expect.it('to be non-empty') }); }) + .addAssertion(' [not] to have failed', function (expect, result) { + expect(result.code, '[not] to be greater than', 0); + }) .addAssertion(' [not] to have test count ', function ( expect, result, @@ -125,15 +128,34 @@ exports.mixinMochaAssertions = function (expect) { } ) .addAssertion( - ' [not] to have failed with error ', - function (expect, result, err) { - expect(result, '[not] to have failed').and('[not] to satisfy', { - failures: expect.it('to have an item satisfying', { - err: expect.it('to satisfy', err).or('to satisfy', {message: err}) - }) + ' [not] to have failed with (error|errors) ', + function (expect, result, errors) { + Array.prototype.slice.call(arguments, 2).forEach(function (error) { + expect(result, '[not] to have failed').and('[not] to satisfy', { + failures: expect.it('to have an item satisfying', { + err: expect + .it('to satisfy', error) + .or('to satisfy', {message: error}) + }) + }); }); } ) + .addAssertion(' [not] to have (error|errors) ', function ( + expect, + result, + errors + ) { + Array.prototype.slice.call(arguments, 2).forEach(function (error) { + expect(result, '[not] to satisfy', { + failures: expect.it('to have an item satisfying', { + err: expect + .it('to satisfy', error) + .or('to satisfy', {message: error}) + }) + }); + }); + }) .addAssertion( ' [not] to have passed (test|tests) ', function (expect, result, titles) { @@ -253,5 +275,11 @@ exports.mixinMochaAssertions = function (expect) { output ) { expect(result.output, '[not] to satisfy', output); - }); + }) + .addAssertion( + ' to have [exit] code ', + function (expect, result, code) { + expect(result.code, 'to be', code); + } + ); };