beforeEach and afterEach don't apply to nested test cases
Opened this issue · 1 comments
Mimickal commented
Mocha in Node.js would run this outer beforeEach
function before all tests that occur within the top-level describe
block, including those nested within inner describe
blocks. Pocha does not apply the beforeEach
to the test cases within inner describe
blocks.
This code demonstrates this behavior. Note that "before each" is printed only once, showing that it was not run for "inner test":
from pocha import describe, beforeEach, it
@describe('tests')
def tests():
@beforeEach
def before():
print('before each')
@it('outer')
def outer():
print('outer')
@describe('inner')
def inner():
@it('inner test')
def inner_test():
print('inner test')
outputs
tests
before each
outer
✓ outer
inner
inner test
✓ inner test