Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: When nesting describers and the describer parent doesn't have test it will skip the beforeEach #1138

Open
hjJunior opened this issue Apr 17, 2024 · 0 comments
Labels

Comments

@hjJunior
Copy link

What Happened

Giving the following structure with nested blocks:

beforeEach(fn () => dump('root block called'));

describe('#block1', function () {
  beforeEach(fn() => dump('#block1'));

  describe('#block1->subBlock#1', function () {
    beforeEach(fn() => dump('#block1->subBlock#1'));

    it('testing', function () {});
  });
});

I would expect the beforeEach from #block1 to be executed

How to Reproduce

  • Create nested blocks with describe, each one having a beforeEach
  • Add any test only on the last child of describe

Example

describe('#block1', function () {
  beforeEach(fn() => dump('#block1'));

  describe('#block1->subBlock#1', function () {
    beforeEach(fn() => dump('#block1->subBlock#1'));

    it('testing', function () {});
  });
});

Sample Repository

No response

Pest Version

2.34.7

PHP Version

8.2.0

Operation System

macOS

Notes

The root beforeEach is executed even when there is no test in same level, you can reproduce it by running the first code provided on "What Happened" section, you will notice that root block called is printed on terminal

@hjJunior hjJunior added the bug label Apr 17, 2024
@hjJunior hjJunior changed the title [Bug]: When nesting describers and the parent describe doesn't have test it will skip the beforeEach [Bug]: When nesting describers and the describer parent doesn't have test it will skip the beforeEach Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant