mirror of
https://github.com/pestphp/pest.git
synced 2026-04-20 22:20:17 +02:00
26345fd9f4aad848773834b91df347fe1018e3a9
Fixes issue where datasets were not applied when using method chaining patterns like beforeEach()->with([...]) or describe()->with([...]) inside nested describe blocks. Root cause: Multiple functions were using Backtrace::file() which returns the immediate caller's filename. This breaks when called through method chaining because the backtrace returns internal Pest files instead of the test file. Solution: Use Backtrace::testFile() which walks the entire backtrace to find the actual test file being executed. This matches the pattern already used by test() and describe() functions. Changes in src/Functions.php: - beforeEach(): Use testFile() to fix beforeEach()->with() pattern - afterEach(): Use testFile() for consistency with beforeEach() - beforeAll(): Use testFile() for better error messages - afterAll(): Use testFile() for better error messages - pest(): Use testFile() to fix pest()->beforeEach() pattern - uses(): Use testFile() for consistency with pest() - covers(): Use testFile() for correct test file context - mutates(): Use testFile() for correct test file context Changes in src/PendingCalls/DescribeCall.php: - __destruct(): Force BeforeEachCall destructor before test creation - __call(): Use $this->filename instead of Backtrace, more efficient - __call(): Properly merge describing context for nested describe blocks Fixes patterns: - beforeEach()->with([...]) - describe()->with([...]) - pest()->beforeEach()->with([...] Tests passing: - tests/Features/Describe.php (all dataset tests) - tests/Hooks/BeforeEachTest.php (global hook execution) - tests/Features/Expect/toMatchSnapshot.php (28 tests)
Pest v4 Now Available: Read the announcement ».
Pest is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
- Explore our docs at pestphp.com »
- Follow the creator Nuno Maduro:
- YouTube: youtube.com/@nunomaduro — Videos every week
- Twitch: twitch.tv/nunomaduro — Live coding on Mondays, Wednesdays, and Fridays at 9PM UTC
- Twitter / X: x.com/enunomaduro
- LinkedIn: linkedin.com/in/nunomaduro
- Instagram: instagram.com/enunomaduro
- Tiktok: tiktok.com/@enunomaduro
Sponsors
We cannot thank our sponsors enough for their incredible support in funding Pest's development. Their contributions have been instrumental in making Pest the best it can be. For those who are interested in becoming a sponsor, please visit Nuno Maduro's Sponsor page at github.com/sponsors/nunomaduro.
Platinum Sponsors
Gold Sponsors
Premium Sponsors
- Forge
- Zapiet
- Localazy
- Load Forge
- DocuWriter.ai
- Route4Me
- Devtools for Livewire
- Nerdify
- Akaunting
- LambdaTest
Pest is an open-sourced software licensed under the MIT license.
Languages
PHP
99.3%
HTML
0.6%
