[4.x] beforeEach runs even when skipped
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 11.7k
- Forks
- 538
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 8
Description
What Happened
beforeEach runs before checking skip() both when on test or directly on beforeEach.
I would expect that skip check takes precedence.
How to Reproduce
beforeEach(fn () => dump('beforeEach'))
->skip(fn () => dump('skip'));
test('should not run', fn () => dump('this test should not run'));
output:
"beforeEach" // tests\Feature\Api\pestTest.php:3
"skip" // tests\Feature\Api\pestTest.php:4
This test was ignored.
Sample Repository
No response
Pest Version
3.7.1
PHP Version
8.3.14
Operation System
Windows
Notes
in case it's significant: Pest in Laravel app
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example in tests\Feature\Api\pestTest.php using Pest 3.7.1, PHP 8.3.14, and the reported Laravel setup. Trace the handling of beforeEach and skip() to determine their execution order. Done means a skipped test does not run its beforeEach callback, while the skip is still reported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100