Louis 26345fd9f4 fix: dataset inheritance with method chaining (beforeEach()->with(), describe()->with())
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)
2025-11-05 17:46:52 +01:00
2025-08-20 14:50:15 +01:00
2020-05-11 18:38:30 +02:00
2024-01-25 18:06:35 +01:00
2025-07-22 11:39:34 +01:00
2025-04-03 17:23:39 +01:00
2025-10-29 22:45:27 +00:00
2020-08-04 12:54:49 +03:00
2024-12-01 20:41:34 +00:00
2025-10-29 22:45:27 +00:00
2020-05-11 18:38:30 +02:00
2025-03-29 17:44:06 +00:00
2025-09-18 20:13:01 +01:00
2025-10-29 22:45:27 +00:00
2025-08-20 15:30:59 +01:00

PEST

GitHub Workflow Status (master) Total Downloads Latest Version License


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.

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

Pest is an open-sourced software licensed under the MIT license.

Description
Pest is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
Readme 6.4 MiB
Languages
PHP 99.3%
HTML 0.6%