mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Execute all parent beforeEach and afterEach functions for each test
This commit is contained in:
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -25,3 +25,19 @@ it('gets executed before each test once again', function () {
|
||||
beforeEach(function () {
|
||||
$this->bar++;
|
||||
});
|
||||
|
||||
describe('outer', function () {
|
||||
beforeEach(function () {
|
||||
$this->bar++;
|
||||
});
|
||||
|
||||
describe('inner', function () {
|
||||
beforeEach(function () {
|
||||
$this->bar++;
|
||||
});
|
||||
|
||||
it('should call all parent beforeEach functions', function () {
|
||||
expect($this->bar)->toBe(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user