Skip to content

Test case skip()ed, beforeEach() hook still executed, afterEach() missed #2546

@s100

Description

@s100

This with Mocha 3.1.2. Source test file:

"use strict";
describe('outer', function() {

  beforeEach(function() {
    console.log("A");
    this.skip();
  });

  describe('inner', function() {
    beforeEach(function() {
      console.log("B");
    });

    it('test case', function() {
      console.log("C");
    });

    afterEach(function() {
      console.log("Y");
    });
  });

  afterEach(function() {
    console.log("Z");
  });
});

Expected output: either "B" and "Y" should be printed, or neither "B" nor "Y" should be printed.

Actual output: "B" is printed, but not "Y":

  outer
    inner
A
B
      - test case


  0 passing (11ms)
  1 pending

In general,

  • If I call skip(), then I would not expect that inner beforeEach blocks would be executed.
  • If a beforeEach block is executed, then the corresponding afterEach blocks should also be executed, for symmetry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: buga defect, confirmed by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions