Execute all parent beforeEach and afterEach functions for each test

This commit is contained in:
jshayes
2024-10-11 23:32:45 -04:00
parent 0c57142c03
commit a6cd83665c
13 changed files with 77 additions and 22 deletions

View File

@ -26,3 +26,25 @@ it('gets executed after the test', function () {
afterEach(function () {
$this->state->bar = 2;
});
describe('outer', function () {
afterEach(function () {
$this->state->bar++;
});
describe('inner', function () {
afterEach(function () {
$this->state->bar++;
});
it('does not get executed before the test', function () {
expect($this->state)->toHaveProperty('bar');
expect($this->state->bar)->toBe(2);
});
it('should call all parent afterEach functions', function () {
expect($this->state)->toHaveProperty('bar');
expect($this->state->bar)->toBe(4);
});
});
});