From 5e6f30a4db03fae38569267db62911bef7bd8045 Mon Sep 17 00:00:00 2001 From: jfatr Date: Tue, 15 Sep 2026 14:08:52 +0200 Subject: [PATCH] fix: skip the frames of Pest by its own directory, not by the name of the checkout `Backtrace::backtrace()` skipped a frame when its path held `pest/src`, so a checkout of this repository in a directory with any other name, such as `pest5`, returned `src/Support/Backtrace.php` as the file of the caller and `tests/Unit/Support/Backtrace.php` failed. The frame check now compares against the directory that holds this file, which is the same directory whether Pest runs from its own checkout or from `vendor/pestphp/pest`, and the global that marked the internal test suite has no reader left. Co-Authored-By: Claude Opus 5 --- src/Support/Backtrace.php | 6 +----- tests/Pest.php | 2 -- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Support/Backtrace.php b/src/Support/Backtrace.php index 8ad285c0b..872000867 100644 --- a/src/Support/Backtrace.php +++ b/src/Support/Backtrace.php @@ -99,11 +99,7 @@ private static function backtrace(): array continue; } - if (($GLOBALS['__PEST_INTERNAL_TEST_SUITE'] ?? false) && str_contains($trace['file'], 'pest'.DIRECTORY_SEPARATOR.'src')) { - continue; - } - - if (str_contains($trace['file'], DIRECTORY_SEPARATOR.'pestphp'.DIRECTORY_SEPARATOR.'pest'.DIRECTORY_SEPARATOR.'src')) { + if (str_starts_with($trace['file'], dirname(__DIR__).DIRECTORY_SEPARATOR)) { continue; } diff --git a/tests/Pest.php b/tests/Pest.php index e9433dc87..98a30f411 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -5,8 +5,6 @@ error_reporting(E_ALL); -$GLOBALS['__PEST_INTERNAL_TEST_SUITE'] = true; - pest()->project()->github('pestphp/pest'); pest()->in('PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder')->use(CustomTestCaseInSubFolder::class);