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.
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:
Output:
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.