Skip to content

fix: beforeEach/afterEach leaking into sibling describe blocks with same nested name - #1850

Open
one-git-wonder wants to merge 4 commits into
pestphp:5.xfrom
one-git-wonder:fix/heirarchical-test-naming
Open

one-git-wonder wants to merge 4 commits into
pestphp:5.xfrom
one-git-wonder:fix/heirarchical-test-naming

Conversation

@one-git-wonder

Copy link
Copy Markdown

What:

  • Bug Fix

Description:

beforeEach/afterEach hooks registered inside a nested describe block leaked into tests in a sibling describe block that shared the same inner describe name, producing misleading ErrorException: Undefined property errors.

Replace the loose membership check with a strict prefix check. A hook now fires only if its entire describe path is a prefix of the test's describe path, which correctly scopes hooks to their own hierarchy while still allowing outer describe hooks to cascade into nested describes.

Related:

#1522

@nunomaduro

Copy link
Copy Markdown
Member

thank you! can you rebase this?

@one-git-wonder
one-git-wonder force-pushed the fix/heirarchical-test-naming branch from a164bb1 to a161134 Compare October 12, 2026 10:50
@one-git-wonder

Copy link
Copy Markdown
Author

thank you! can you rebase this?

rebased now

@one-git-wonder
one-git-wonder force-pushed the fix/heirarchical-test-naming branch from a161134 to fdbbb70 Compare October 20, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants