Skip to content

🐛 Bug: before() and after() hooks run in a test file with only skipped tests #2456

@fabiosantoscode

Description

@fabiosantoscode

I recently stumbled upon this. A test file containing the following:

describe('something', () => {
  before(() => { console.log('I should really not run') })
  it.skip('skipped test', () => {})
  after(() => { console.log('I should really not run either') })
})

Will produce the following output:

  something
I should really not run
    - skipped test
I should really not run either


  0 passing (8ms)
  1 pending

The workaround is to skip the entire describe() instead of the individual tests, so I wonder if there's interest in fixing this. Should a before or after function be preparing or cleaning up a test which didn't run?

Thanks for this amazing piece of software ❤️

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: accepting prsMocha can use your help with this one!type: buga defect, confirmed by a maintainer

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions