mirror of
https://github.com/pestphp/pest.git
synced 2026-03-11 02:07:23 +01:00
Fix an issue where beforeEach/afterEach functions were called on other describe blocks with the same name
This commit is contained in:
@ -48,3 +48,55 @@ describe('outer', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('matching describe block names', function () {
|
||||
afterEach(function () {
|
||||
$this->state->foo = 1;
|
||||
});
|
||||
|
||||
describe('outer', function () {
|
||||
afterEach(function () {
|
||||
$this->state->foo++;
|
||||
});
|
||||
|
||||
describe('middle', function () {
|
||||
afterEach(function () {
|
||||
$this->state->foo++;
|
||||
});
|
||||
|
||||
describe('inner', function () {
|
||||
afterEach(function () {
|
||||
$this->state->foo++;
|
||||
});
|
||||
|
||||
it('does not get executed before the test', function () {
|
||||
expect($this)->not->toHaveProperty('foo');
|
||||
});
|
||||
|
||||
it('should call all parent afterEach functions', function () {
|
||||
expect($this->state->foo)->toBe(4);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('middle', function () {
|
||||
it('does not get executed before the test', function () {
|
||||
expect($this)->not->toHaveProperty('foo');
|
||||
});
|
||||
|
||||
it('should not call afterEach functions for sibling describe blocks with the same name', function () {
|
||||
expect($this)->not->toHaveProperty('foo');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inner', function () {
|
||||
it('does not get executed before the test', function () {
|
||||
expect($this)->not->toHaveProperty('foo');
|
||||
});
|
||||
|
||||
it('should not call afterEach functions for descendent of sibling describe blocks with the same name', function () {
|
||||
expect($this)->not->toHaveProperty('foo');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user