Skip to content

Commit

Permalink
backout 02294a3 (via #3362); closes #3569
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Dec 10, 2018
1 parent b5c0fb0 commit 6df0e84
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 63 deletions.
14 changes: 3 additions & 11 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,17 +595,9 @@ Runner.prototype.runTests = function(suite, fn) {
}

test.state = 'passed';

// For supporting conditional fail in afterEach hook,
// run emit pass after an afterEach hook.
// See, https://github.com/mochajs/mocha/wiki/HOW-TO:-Conditionally-fail-a-test-after-completion
self.hookUp('afterEach', function(err, errSuite) {
if (test.state === 'passed') {
self.emit('pass', test);
}
self.emit('test end', test);
next(err, errSuite);
});
self.emit('pass', test);
self.emit('test end', test);
self.hookUp('afterEach', next);
});
});
}
Expand Down

This file was deleted.

17 changes: 10 additions & 7 deletions test/integration/fixtures/multiple-done.fixture.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
'use strict';

describe('suite', function() {
beforeEach(function(done) {
done();
done();
});
// The suite below should result in an additional error, but does
// not. Uncomment once this bug is resolved.

it('test', function() {});
});
// describe('suite', function() {
// beforeEach(function(done) {
// done();
// done();
// });

// it('test', function() {});
// });

it('should fail in a test-case', function (done) {
process.nextTick(function () {
Expand Down
5 changes: 2 additions & 3 deletions test/integration/hook-err.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('hook error handling', function() {
describe('after each hook error', function() {
before(run('hooks/afterEach-hook-error.fixture.js'));
it('should verify results', function() {
assert.deepEqual(lines, ['test 1', 'after', bang, 'test 3']);
assert.deepEqual(lines, ['test 1', 'after', bang + 'test 3']);
});
});

Expand All @@ -62,8 +62,7 @@ describe('hook error handling', function() {
'1-2 before each',
'1-2 test 1',
'1-2 after each',
bang,
'1 after each',
bang + '1 after each',
'root after each',
'1-2 after',
'1 after',
Expand Down
20 changes: 2 additions & 18 deletions test/integration/hooks.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';

var assert = require('assert');
var helpers = require('./helpers');
var runMocha = require('./helpers').runMocha;
var splitRegExp = require('./helpers').splitRegExp;
var args = ['--reporter', 'dot'];

describe('hooks', function() {
it('are ran in correct order', function(done) {
helpers.runMocha('cascade.fixture.js', args, function(err, res) {
runMocha('cascade.fixture.js', args, function(err, res) {
var lines, expected;

if (err) {
Expand Down Expand Up @@ -49,20 +49,4 @@ describe('hooks', function() {
done();
});
});

it('can fail a test in an afterEach hook', function(done) {
helpers.runMochaJSON(
'hooks/afterEach-hook-conditionally-fail.fixture.js',
[],
function(err, res) {
if (err) {
done(err);
return;
}
assert.equal(res.stats.passes, 2);
assert.equal(res.stats.failures, 1);
done();
}
);
});
});
4 changes: 2 additions & 2 deletions test/integration/multiple-done.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('multiple calls to done()', function() {
it('results in failures', function() {
assert.equal(res.stats.pending, 0, 'wrong "pending" count');
assert.equal(res.stats.passes, 1, 'wrong "passes" count');
assert.equal(res.stats.failures, 2, 'wrong "failures" count');
assert.equal(res.stats.failures, 1, 'wrong "failures" count');
});

it('throws a descriptive error', function() {
Expand All @@ -35,7 +35,7 @@ describe('multiple calls to done()', function() {

it('results in failures', function() {
assert.equal(res.stats.pending, 0, 'wrong "pending" count');
assert.equal(res.stats.passes, 0, 'wrong "passes" count');
assert.equal(res.stats.passes, 1, 'wrong "passes" count');
assert.equal(res.stats.failures, 1, 'wrong "failures" count');
});

Expand Down
6 changes: 5 additions & 1 deletion test/integration/uncaught.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ describe('uncaught exceptions', function() {
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.passes, 1);
assert.equal(res.stats.failures, 1);

assert.equal(
res.failures[0].title,
'should bail if a successful test asynchronously fails'
);
assert.equal(
res.passes[0].title,
'should bail if a successful test asynchronously fails'
);

assert.equal(res.code, 1);
done();
Expand Down

0 comments on commit 6df0e84

Please sign in to comment.