diff --git a/test/integration/hooks.spec.js b/test/integration/hooks.spec.js index ed3c25b2b1..e68aa66b64 100644 --- a/test/integration/hooks.spec.js +++ b/test/integration/hooks.spec.js @@ -10,7 +10,10 @@ describe('hooks', function () { runMocha('cascade.fixture.js', args, function (err, res) { var lines, expected; - assert(!err); + if (err) { + done(err); + return; + } lines = res.output.split(splitRegExp).map(function (line) { return line.trim(); diff --git a/test/integration/only.spec.js b/test/integration/only.spec.js index b37a4b263e..098af6786c 100644 --- a/test/integration/only.spec.js +++ b/test/integration/only.spec.js @@ -7,7 +7,10 @@ describe('.only()', function () { describe('bdd', function () { it('should run only tests that marked as `only`', function (done) { run('options/only/bdd.fixture.js', ['--ui', 'bdd'], function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 11); assert.equal(res.stats.failures, 0); @@ -20,7 +23,10 @@ describe('.only()', function () { describe('tdd', function () { it('should run only tests that marked as `only`', function (done) { run('options/only/tdd.fixture.js', ['--ui', 'tdd'], function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 8); assert.equal(res.stats.failures, 0); @@ -33,7 +39,10 @@ describe('.only()', function () { describe('qunit', function () { it('should run only tests that marked as `only`', function (done) { run('options/only/qunit.fixture.js', ['--ui', 'qunit'], function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 5); assert.equal(res.stats.failures, 0); diff --git a/test/integration/options.spec.js b/test/integration/options.spec.js index 325fbada8f..be4abf53c5 100644 --- a/test/integration/options.spec.js +++ b/test/integration/options.spec.js @@ -12,7 +12,10 @@ describe('options', function () { it('should fail synchronous specs', function (done) { run('options/async-only-sync.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 1); @@ -25,7 +28,10 @@ describe('options', function () { it('should allow asynchronous specs', function (done) { run('options/async-only-async.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 1); assert.equal(res.stats.failures, 0); @@ -44,7 +50,10 @@ describe('options', function () { it('should stop after the first error', function (done) { run('options/bail.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 1); assert.equal(res.stats.failures, 1); @@ -64,7 +73,10 @@ describe('options', function () { it('should sort tests in alphabetical order', function (done) { run('options/sort*', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 2); assert.equal(res.stats.failures, 0); @@ -84,7 +96,10 @@ describe('options', function () { it('should run the generated test suite', function (done) { run('options/delay.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 1); assert.equal(res.stats.failures, 0); @@ -98,7 +113,10 @@ describe('options', function () { it('should throw an error if the test suite failed to run', function (done) { run('options/delay-fail.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 1); @@ -115,7 +133,10 @@ describe('options', function () { it('runs specs matching a string', function (done) { args = ['--grep', 'match']; run('options/grep.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 2); assert.equal(res.stats.failures, 0); @@ -128,7 +149,10 @@ describe('options', function () { it('with RegExp like strings(pattern follow by flag)', function (done) { args = ['--grep', '/match/i']; run('options/grep.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 4); assert.equal(res.stats.failures, 0); @@ -140,7 +164,10 @@ describe('options', function () { it('string as pattern', function (done) { args = ['--grep', '.*']; run('options/grep.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 4); assert.equal(res.stats.failures, 1); @@ -154,7 +181,10 @@ describe('options', function () { it('runs specs that do not match the pattern', function (done) { args = ['--grep', 'fail', '--invert']; run('options/grep.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 4); assert.equal(res.stats.failures, 0); @@ -169,7 +199,10 @@ describe('options', function () { it('retries after a certain threshold', function (done) { args = ['--retries', '3']; run('options/retries.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); assert.equal(res.stats.tests, 1); @@ -188,7 +221,10 @@ describe('options', function () { it('succeeds if there are only passed tests', function (done) { run('options/forbid-only/passed.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.code, 0); done(); }); @@ -196,7 +232,10 @@ describe('options', function () { it('fails if there are tests marked only', function (done) { run('options/forbid-only/only.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.code, 1); done(); }); @@ -210,7 +249,10 @@ describe('options', function () { it('succeeds if there are only passed tests', function (done) { run('options/forbid-pending/passed.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.code, 0); done(); }); @@ -218,7 +260,10 @@ describe('options', function () { it('fails if there are tests marked skip', function (done) { run('options/forbid-pending/skip.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.code, 1); done(); }); @@ -226,7 +271,10 @@ describe('options', function () { it('fails if there are pending tests', function (done) { run('options/forbid-pending/pending.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.code, 1); done(); }); diff --git a/test/integration/pending.spec.js b/test/integration/pending.spec.js index 19ae30ad3a..f5a400f089 100644 --- a/test/integration/pending.spec.js +++ b/test/integration/pending.spec.js @@ -8,7 +8,10 @@ describe('pending', function () { describe('pending specs', function () { it('should be created by omitting a function', function (done) { run('pending/spec.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 1); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 0); @@ -22,7 +25,10 @@ describe('pending', function () { describe('in spec', function () { it('should immediately skip the spec and run all others', function (done) { run('pending/skip-sync-spec.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 1); assert.equal(res.stats.passes, 1); assert.equal(res.stats.failures, 0); @@ -35,7 +41,10 @@ describe('pending', function () { describe('in before', function () { it('should skip all suite specs', function (done) { run('pending/skip-sync-before.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 2); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 0); @@ -48,7 +57,10 @@ describe('pending', function () { describe('in beforeEach', function () { it('should skip all suite specs', function (done) { run('pending/skip-sync-beforeEach.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 2); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 0); @@ -63,7 +75,10 @@ describe('pending', function () { describe('in spec', function () { it('should immediately skip the spec and run all others', function (done) { run('pending/skip-async-spec.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 1); assert.equal(res.stats.passes, 1); assert.equal(res.stats.failures, 0); @@ -76,7 +91,10 @@ describe('pending', function () { describe('in before', function () { it('should skip all suite specs', function (done) { run('pending/skip-async-before.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 2); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 0); @@ -89,7 +107,10 @@ describe('pending', function () { describe('in beforeEach', function () { it('should skip all suite specs', function (done) { run('pending/skip-sync-beforeEach.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 2); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 0); diff --git a/test/integration/regression.spec.js b/test/integration/regression.spec.js index 74f32f8081..56791f2faf 100644 --- a/test/integration/regression.spec.js +++ b/test/integration/regression.spec.js @@ -15,7 +15,10 @@ describe('regressions', function () { return (res.output.match(pattern) || []).length; }; - assert(!err); + if (err) { + done(err); + return; + } assert.equal(occurences('testbody1'), 1); assert.equal(occurences('testbody2'), 1); assert.equal(occurences('testbody3'), 1); @@ -36,7 +39,10 @@ describe('regressions', function () { var simpleUiPath = path.join(__dirname, 'fixtures', 'regression', '1794', 'simple-ui.js'); var args = ['--require', simpleUiPath, '--ui', 'simple-ui']; run('regression/1794/issue-1794.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.code, 0, 'Custom UI should be loaded'); done(); }); @@ -47,7 +53,10 @@ describe('regressions', function () { // Could easily take longer on even weaker machines (Travis-CI containers for example). this.timeout(120000); run('regression/issue-1991.fixture.js', [], function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(/process out of memory/.test(res.output), false, 'fixture\'s process out of memory!'); assert.equal(res.code, 0, 'Runnable fn (it/before[Each]/after[Each]) references should be deleted to avoid memory leaks'); done(); @@ -68,7 +77,10 @@ describe('regressions', function () { it('issue-2315: cannot read property currentRetry of undefined', function (done) { runJSON('regression/issue-2315.fixture.js', [], function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 1); @@ -80,7 +92,10 @@ describe('regressions', function () { it('issue-2406: should run nested describe.only suites', function (done) { this.timeout(2000); runJSON('regression/issue-2406.fixture.js', [], function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 2); assert.equal(res.stats.failures, 0); @@ -91,7 +106,10 @@ describe('regressions', function () { it('issue-2417: should not recurse infinitely with .only suites nested within each other', function () { runJSON('regression/issue-2417.fixture.js', [], function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 1); assert.equal(res.stats.failures, 0); @@ -101,7 +119,10 @@ describe('regressions', function () { it('issue-1417 uncaught exceptions from async specs', function (done) { runJSON('regression/issue-1417.fixture.js', [], function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 2); diff --git a/test/integration/reporters.spec.js b/test/integration/reporters.spec.js index 19b4d8e30c..9bf8df289c 100644 --- a/test/integration/reporters.spec.js +++ b/test/integration/reporters.spec.js @@ -68,7 +68,10 @@ describe('reporters', function () { var args = ['--reporter=' + reporterAtARelativePath]; run('passing.fixture.js', args, function (err, result) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(result.code, 0); done(); }); @@ -81,7 +84,10 @@ describe('reporters', function () { var args = ['--reporter=' + reporterAtAnAbsolutePath]; run('passing.fixture.js', args, function (err, result) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(result.code, 0); done(); }); diff --git a/test/integration/retries.spec.js b/test/integration/retries.spec.js index 9d9301ad78..6197c43ca8 100644 --- a/test/integration/retries.spec.js +++ b/test/integration/retries.spec.js @@ -10,7 +10,10 @@ describe('retries', function () { helpers.runMocha('retries/hooks.fixture.js', args, function (err, res) { var lines, expected; - assert(!err); + if (err) { + done(err); + return; + } lines = res.output.split(helpers.splitRegExp).map(function (line) { return line.trim(); @@ -49,7 +52,10 @@ describe('retries', function () { it('should exit early if test passes', function (done) { helpers.runMochaJSON('retries/early-pass.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.passes, 1); assert.equal(res.stats.failures, 0); assert.equal(res.tests[0].currentRetry, 1); @@ -61,7 +67,10 @@ describe('retries', function () { it('should let test override', function (done) { helpers.runMochaJSON('retries/nested.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 1); assert.equal(res.stats.tests, 1); @@ -75,7 +84,10 @@ describe('retries', function () { helpers.runMocha('retries/async.fixture.js', args, function (err, res) { var lines, expected; - assert(!err); + if (err) { + done(err); + return; + } lines = res.output.split(helpers.splitRegExp).map(function (line) { return line.trim(); diff --git a/test/integration/suite.spec.js b/test/integration/suite.spec.js index f497e72652..4af47697f7 100644 --- a/test/integration/suite.spec.js +++ b/test/integration/suite.spec.js @@ -8,7 +8,10 @@ describe('suite w/no callback', function () { this.timeout(2000); it('should throw a helpful error message when a callback for suite is not supplied', function (done) { run('suite/suite-no-callback.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } var result = res.output.match(/no callback was supplied/) || []; assert.equal(result.length, 1); done(); @@ -20,7 +23,10 @@ describe('skipped suite w/no callback', function () { this.timeout(2000); it('should not throw an error when a callback for skipped suite is not supplied', function (done) { run('suite/suite-skipped-no-callback.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } var pattern = new RegExp('Error', 'g'); var result = res.output.match(pattern) || []; assert.equal(result.length, 0); @@ -33,7 +39,10 @@ describe('skipped suite w/ callback', function () { this.timeout(2000); it('should not throw an error when a callback for skipped suite is supplied', function (done) { run('suite/suite-skipped-callback.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } var pattern = new RegExp('Error', 'g'); var result = res.output.match(pattern) || []; assert.equal(result.length, 0); diff --git a/test/integration/timeout.spec.js b/test/integration/timeout.spec.js index 4e0f989e86..c51ba774de 100644 --- a/test/integration/timeout.spec.js +++ b/test/integration/timeout.spec.js @@ -7,7 +7,10 @@ var args = []; describe('this.timeout()', function () { it('is respected by sync and async suites', function (done) { run('timeout.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 2); diff --git a/test/integration/uncaught.spec.js b/test/integration/uncaught.spec.js index 92e39c195e..9a3dadbbbd 100644 --- a/test/integration/uncaught.spec.js +++ b/test/integration/uncaught.spec.js @@ -7,7 +7,10 @@ var args = []; describe('uncaught exceptions', function () { it('handles uncaught exceptions from hooks', function (done) { run('uncaught-hook.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 1); @@ -21,7 +24,10 @@ describe('uncaught exceptions', function () { it('handles uncaught exceptions from async specs', function (done) { run('uncaught.fixture.js', args, function (err, res) { - assert(!err); + if (err) { + done(err); + return; + } assert.equal(res.stats.pending, 0); assert.equal(res.stats.passes, 0); assert.equal(res.stats.failures, 2);