Skip to content

🐛 Bug: afterEach halts suite and/or causes simultaneous failure and pass #1635

@glenjamin

Description

@glenjamin

This is a common pattern with tools like sinon or nock - to have afterEach do some standard verification at the end of each test.

I'm fairly sure this used to work - not sure what's changed.

var assert = require('assert');

describe("afterEach", function() {
    var verificationFlag;
    beforeEach(function() {
        verificationFlag = 0;
    });
    afterEach(function() {
        assert.equal(verificationFlag, 1);
    });

    it("0", function() { })
    it("1", function() { verificationFlag = 1 })
    it("2", function() { verificationFlag = 2 })
});

Expected output: 3 tests, 3 failures
Actual output: 1 test, 1 pass, 1 fail (from hook)

Metadata

Metadata

Assignees

No one assigned

    Labels

    semver-majorimplementation requires increase of "major" version number; "breaking changes"status: accepting prsMocha can use your help with this one!type: buga defect, confirmed by a maintainer

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions