Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AfterEach does not run when test fails #42

Open
Bareus opened this issue Feb 22, 2018 · 0 comments
Open

AfterEach does not run when test fails #42

Bareus opened this issue Feb 22, 2018 · 0 comments

Comments

@Bareus
Copy link

Bareus commented Feb 22, 2018

It seems like afterEach hooks do not run when a test fails in mocha.parallel. In standard mocha an afterEach hook runs even when a test fails.

Here an example:

parallel("Test Suit Collection", function() {
    let tmp = 0;
    afterEach("cleanUp", function() {
        console.log(tmp);
    });

    it("test 1", async function() {
        await sleep(1000);
        expect(true).to.be.false;
        tmp = 1;
    });

    it("test 2", async function() {
        await sleep(1000);
        expect(true).to.be.true;
        tmp = 2;
    });
});

Output:

Test Suit Collection
2
    1) test 1
    √ test 2 (1003ms)

As you can see the afterEach for test 1 never run, while it runs for test 2. Luckily I can still work with the after hook so this is not a big problem for me, but it would be nice if you can fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant