Skip to content

'before' and 'after' run in later suites even with '--bail' #690

Closed

Description

I don't think this should be the case? Shouldn't it skip everything else, including befores and afters?

$ mocha --version
1.7.0

$ cat testing/a.js
describe('Initial test', function() {
    before(function() {
        console.log('initial before');
    });

    describe('test will fail', function() {

        it('will fail', function() {
            throw new Error('failed');
        });
    });

    after(function() {
        console.log('calling after');
    });
});

$ cat testing/b.js 
describe('Second test', function() {
    before(function() {
        console.log('second before');
    });

    describe('second test does not matter', function() {

        it('this test should not run', function() {
            throw new Error('I do not matter');
        });
    });

    after(function() {
        console.log('calling second after');
    });
});


$ mocha --bail testing/

initial before
․calling after
second before // SHOULD NEVER BE CALLED
calling second after // SHOULD NEVER BE CALLED

✖ 1 of 2 tests failed:

1) Initial test test will fail will fail:
    Error: failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions