From be90610f1784ea19ffaa508be4a62d00f8de8362 Mon Sep 17 00:00:00 2001 From: Willem-Jaap Date: Tue, 30 Dec 2025 09:24:05 +0100 Subject: [PATCH] feat: add pest only function to mark each test in a file as only --- src/Configuration.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Configuration.php b/src/Configuration.php index fb4f45a4..4ca74d38 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Pest; +use Pest\PendingCalls\BeforeEachCall; use Pest\PendingCalls\UsesCall; /** @@ -24,7 +25,7 @@ final readonly class Configuration public function __construct( string $filename, ) { - $this->filename = str_ends_with($filename, DIRECTORY_SEPARATOR.'Pest.php') ? dirname($filename) : $filename; + $this->filename = str_ends_with($filename, DIRECTORY_SEPARATOR . 'Pest.php') ? dirname($filename) : $filename; } /** @@ -62,6 +63,14 @@ final readonly class Configuration return (new UsesCall($this->filename, []))->group(...$groups); } + /** + * Marks all tests in the current file to be run exclusively. + */ + public function only(): void + { + (new BeforeEachCall(TestSuite::getInstance(), $this->filename))->only(); + } + /** * Depending on where is called, it will extend the given classes and traits globally or locally. */