Rector
Source code: github.com/pestphp/pest-plugin-rector
Pest's Rector plugin provides automated refactoring rules powered by Rector. It helps simplify and modernize your test code, and upgrade between major Pest versions.
To get started, require the plugin via Composer and install Rector:
1composer require pestphp/pest-plugin-rector --dev2composer require rector/rector --dev
Rule Sets
You can configure which rules to apply by using predefined rule sets in your rector.php file.
Pest Code Quality
Converts raw PHP assertions to Pest's built-in matchers, chains multiple expect() calls on the same value, and simplifies redundant patterns.
1use Pest\Rector\Set\PestSetList;2use Rector\Config\RectorConfig;3 4return RectorConfig::configure()5 ->withPaths([__DIR__ . '/tests'])6 ->withSets([7 PestSetList::PEST_CODE_QUALITY,8 PestSetList::PEST_CHAIN,9 ]);
The PEST_CHAIN set merges consecutive expect() calls into a single chained expectation and orders type checks first. It is best applied alongside PEST_CODE_QUALITY so that newly introduced matchers can be chained together.
PHPUnit To Pest Migration
Converts PHPUnit assertion methods and expectException() patterns to Pest's expect() API. These are structural transformations, so you should review the result after applying them.
1use Pest\Rector\Set\PestSetList;2use Rector\Config\RectorConfig;3 4return RectorConfig::configure()5 ->withPaths([__DIR__ . '/tests'])6 ->withSets([7 PestSetList::PEST_MIGRATION,8 ]);
Laravel
Converts Illuminate\Support\Str equality checks to Pest's string case matchers, such as toBeSnakeCase() and toBeKebabCase(). This set requires the illuminate/support package.
1use Pest\Rector\Set\PestSetList;2use Rector\Config\RectorConfig;3 4return RectorConfig::configure()5 ->withPaths([__DIR__ . '/tests'])6 ->withSets([7 PestSetList::PEST_LARAVEL,8 ]);
Browser
Converts generic expect($page->getter())->matcher() patterns into the dedicated assertions provided by the Browser Testing plugin, resulting in more readable tests and clearer failure messages. This set requires the pestphp/pest-plugin-browser package.
1use Pest\Rector\Set\PestSetList;2use Rector\Config\RectorConfig;3 4return RectorConfig::configure()5 ->withPaths([__DIR__ . '/tests'])6 ->withSets([7 PestSetList::PEST_BROWSER,8 ]);
Pest Version Upgrades
Upgrade your test suite between major Pest versions.
1use Pest\Rector\Set\PestLevelSetList; 2 3// Upgrade from Pest v2 to v3 4return RectorConfig::configure() 5 ->withPaths([__DIR__ . '/tests']) 6 ->withLevelSet(PestLevelSetList::UP_TO_PEST_30); 7 8// Upgrade from Pest v2 or v3 to v4 9return RectorConfig::configure()10 ->withPaths([__DIR__ . '/tests'])11 ->withLevelSet(PestLevelSetList::UP_TO_PEST_40);
Preview & Apply Changes
Run Rector with the --dry-run flag to preview changes before applying them:
1vendor/bin/rector process --dry-run
Once you are satisfied with the proposed changes, run Rector without the flag to apply them:
1vendor/bin/rector process
All Rules
ChainExpectCallsRector
Chains multiple expect() calls on the same value into a single chained expectation
- class:
Pest\Rector\Rules\ChainExpectCallsRector
1-expect($a)->toBe(10);2-expect($a)->toBeInt();3+expect($a)->toBe(10)4+ ->toBeInt();
1-expect($a)->toBe(10);2-expect($b)->toBe(10);3+expect($a)->toBe(10)4+ ->and($b)->toBe(10);
ConvertAssertToExpectRector
Converts PHPUnit assertion method calls to Pest expect() chains
- class:
Pest\Rector\Rules\ConvertAssertToExpectRector
1-$this->assertEquals('expected', $result);2-$this->assertTrue($value);3-$this->assertCount(3, $items);4+expect($result)->toEqual('expected');5+expect($value)->toBeTrue();6+expect($items)->toHaveCount(3);
ConvertBeforeAllInDescribeRector
Replaces invalid beforeAll() and afterAll() hooks inside describe() with beforeEach() and afterEach()
- class:
Pest\Rector\Rules\ConvertBeforeAllInDescribeRector
1 describe('users', function (): void {2- beforeAll(function (): void {3+ beforeEach(function (): void {4 refreshDatabase();5 });6 });
ConvertExpectExceptionToThrowRector
Converts expectException() and expectExceptionMessage() patterns to expect()->toThrow()
- class:
Pest\Rector\Rules\ConvertExpectExceptionToThrowRector
1-$this->expectException(RuntimeException::class);2-$this->expectExceptionMessage('error');3-doSomething();4+expect(fn () => doSomething())->toThrow(RuntimeException::class, 'error');
EnsureTypeChecksFirstRector
Ensure type-check matchers (e.g. toBeInt, toBeInstanceOf) appear before value assertions in expect() chains and consecutive expects
- class:
Pest\Rector\Rules\EnsureTypeChecksFirstRector
1-expect($a)->toBe(10)->toBeInt();2+expect($a)->toBeInt()->toBe(10);
FixInvalidRepeatValueRector
Normalizes invalid literal repeat() counts to 1
- class:
Pest\Rector\Rules\FixInvalidRepeatValueRector
1 it('retries once', function (): void {2 expect(true)->toBeTrue();3-})->repeat(0);4+})->repeat(1);
RemoveDebugExpectationsRector
Removes debug method calls (dump, dd, ray) from expect chains
- class:
Pest\Rector\Rules\RemoveDebugExpectationsRector
1-expect($user)->dump()->toBeInstanceOf(User::class);2+expect($user)->toBeInstanceOf(User::class);
RemoveOnlyRector
Removes only() from all tests
- class:
Pest\Rector\Rules\RemoveOnlyRector
1-test()->only();2+test();
RemoveRedundantLiteralTypeExpectationRector
Removes redundant literal type expectations when a later matcher keeps the chain meaningful
- class:
Pest\Rector\Rules\RemoveRedundantLiteralTypeExpectationRector
1 expect('pest')2- ->toBeString()3 ->toStartWith('p');
RemoveRedundantPestUsesRector
Removes redundant local Pest uses already configured globally in tests/Pest.php
- class:
Pest\Rector\Rules\RemoveRedundantPestUsesRector
1 // tests/Pest.php contains:2 // pest()->use(RefreshDatabase::class)->in('Feature');3 4 // tests/Feature/UserTest.php5-pest()->use(RefreshDatabase::class, SomeOtherTrait::class);6+pest()->use(SomeOtherTrait::class);
RemoveStaticTestClosureRector
Removes static from Pest test and hook callbacks that use the test case instance
- class:
Pest\Rector\Rules\RemoveStaticTestClosureRector
1-it('uses the test case instance', static function (): void {2+it('uses the test case instance', function (): void {3 expect($this)->not->toBeNull();4 });
SimplifyComparisonExpectationsRector
Converts expect($x > 10)->toBeTrue() to expect($x)->toBeGreaterThan(10)
- class:
Pest\Rector\Rules\SimplifyComparisonExpectationsRector
1-expect($value > 10)->toBeTrue();2-expect($value >= 10)->toBeTrue();3+expect($value)->toBeGreaterThan(10);4+expect($value)->toBeGreaterThanOrEqual(10);
SimplifyExpectNotRector
Simplifies negated expectations by flipping the matcher
- class:
Pest\Rector\Rules\SimplifyExpectNotRector
1-expect(!$condition)->toBeTrue();2+expect($condition)->toBeFalse();
SimplifyFilesystemMatchersRector
Simplifies combined filesystem checks to single Pest matchers
- class:
Pest\Rector\Rules\SimplifyFilesystemMatchersRector
1-expect(is_file($path) && is_readable($path))->toBeTrue();2+expect($path)->toBeReadableFile();
SimplifyToBeTruthyFalsyRector
Converts bool cast assertions to toBeTruthy()/toBeFalsy() matchers
- class:
Pest\Rector\Rules\SimplifyToBeTruthyFalsyRector
1-expect((bool) $value)->toBeTrue();2+expect($value)->toBeTruthy();
SimplifyToLiteralBooleanRector
Simplifies expect($x)->toBe(true) to expect($x)->toBeTrue()
- class:
Pest\Rector\Rules\SimplifyToLiteralBooleanRector
1-expect($value)->toBe(true);2-expect($value)->toBe(null);3+expect($value)->toBeTrue();4+expect($value)->toBeNull();
TapToDeferRector
Replaces deprecated ->tap() method with ->defer() for Pest v3 migration
- class:
Pest\Rector\Rules\Pest2ToPest3\TapToDeferRector
1-expect($value)->tap(fn ($value) => dump($value))->toBe(10);2+expect($value)->defer(fn ($value) => dump($value))->toBe(10);
ToBeTrueNotFalseRector
Simplifies double-negative expectations like ->not->toBeFalse() to ->toBeTrue()
- class:
Pest\Rector\Rules\ToBeTrueNotFalseRector
1-expect($value)->not->toBeFalse();2+expect($value)->toBeTrue();
ToHaveMethodOnClassRector
Changes expect($object)->toHaveMethod() to expect($object::class)->toHaveMethod() for Pest v3
- class:
Pest\Rector\Rules\Pest2ToPest3\ToHaveMethodOnClassRector
1-expect($user)->toHaveMethod('getName');2+expect($user::class)->toHaveMethod('getName');
UseBrowserAriaAndDataAttributeAssertionsRector
Converts expect($page->attribute($selector, 'aria-*'))->toBe($value) to $page->assertAriaAttribute(), and the data-* equivalent (requires the Browser Testing plugin)
- class:
Pest\Rector\Rules\Browser\UseBrowserAriaAndDataAttributeAssertionsRector
1-expect($page->attribute('button', 'aria-label'))->toBe('Close');2-expect($page->attribute('div', 'data-id'))->toBe('123');3+$page->assertAriaAttribute('button', 'label', 'Close');4+$page->assertDataAttribute('div', 'id', '123');
UseBrowserAttributeAssertionsRector
Converts expect($page->attribute($selector, $attr))->toBe($value) to $page->assertAttribute() (requires the Browser Testing plugin)
- class:
Pest\Rector\Rules\Browser\UseBrowserAttributeAssertionsRector
1-expect($page->attribute('img', 'alt'))->toBe('Profile Picture');2+$page->assertAttribute('img', 'alt', 'Profile Picture');
UseBrowserScriptAssertionsRector
Converts expect($page->script($expression))->toBe($value) to $page->assertScript() (requires the Browser Testing plugin)
- class:
Pest\Rector\Rules\Browser\UseBrowserScriptAssertionsRector
1-expect($page->script('document.title'))->toBe('Home Page');2+$page->assertScript('document.title', 'Home Page');
UseBrowserSourceAssertionsRector
Converts expect($page->content())->toContain($html) to $page->assertSourceHas() (requires the Browser Testing plugin)
- class:
Pest\Rector\Rules\Browser\UseBrowserSourceAssertionsRector
1-expect($page->content())->toContain('<h1>Welcome</h1>');2+$page->assertSourceHas('<h1>Welcome</h1>');
UseBrowserUrlAssertionsRector
Converts expect($page->url())->toBe($url) to $page->assertUrlIs() (requires the Browser Testing plugin)
- class:
Pest\Rector\Rules\Browser\UseBrowserUrlAssertionsRector
1-expect($page->url())->toBe('https://example.com/home');2+$page->assertUrlIs('https://example.com/home');
UseBrowserValueAssertionsRector
Converts expect($page->value($selector))->toBe($value) to $page->assertValue() (requires the Browser Testing plugin)
- class:
Pest\Rector\Rules\Browser\UseBrowserValueAssertionsRector
1-expect($page->value('input[name=email]'))->toBe('test@example.com');2+$page->assertValue('input[name=email]', 'test@example.com');
UseEachModifierRector
Converts foreach loops with expect() calls to use the ->each modifier
- class:
Pest\Rector\Rules\UseEachModifierRector
1-foreach ($items as $item) {2- expect($item)->toBeString();3-}4+expect($items)->each->toBeString();
UseInstanceOfMatcherRector
Converts expect($obj instanceof User)->toBeTrue() to expect($obj)->toBeInstanceOf(User::class)
- class:
Pest\Rector\Rules\UseInstanceOfMatcherRector
1-expect($user instanceof User)->toBeTrue();2+expect($user)->toBeInstanceOf(User::class);
UseSequenceMatcherRector
Converts consecutive indexed expect() calls to sequence()
- class:
Pest\Rector\Rules\UseSequenceMatcherRector
1-expect($items[0])->toBe('a');2-expect($items[1])->toBe('b');3+expect($items)->sequence(fn ($e) => $e->toBe('a'), fn ($e) => $e->toBe('b'));
UseStrictEqualityMatchersRector
Converts strict equality expressions to toBe() matcher
- class:
Pest\Rector\Rules\UseStrictEqualityMatchersRector
1-expect($a === $b)->toBeTrue();2+expect($a)->toBe($b);
UseToBeAlphaNumericRector
Converts ctype_alnum() checks to toBeAlphaNumeric() matcher
- class:
Pest\Rector\Rules\UseToBeAlphaNumericRector
1-expect(ctype_alnum($value))->toBeTrue();2+expect($value)->toBeAlphaNumeric();
UseToBeAlphaRector
Converts ctype_alpha() checks to toBeAlpha() matcher
- class:
Pest\Rector\Rules\UseToBeAlphaRector
1-expect(ctype_alpha($value))->toBeTrue();2+expect($value)->toBeAlpha();
UseToBeBetweenRector
Converts expect($value >= $min && $value <= $max)->toBeTrue() to expect($value)->toBeBetween($min, $max)
- class:
Pest\Rector\Rules\UseToBeBetweenRector
1-expect($value >= 1 && $value <= 10)->toBeTrue();2+expect($value)->toBeBetween(1, 10);
UseToBeCamelCaseRector
Converts Str::camel() equality checks to toBeCamelCase() matcher (requires illuminate/support)
- class:
Pest\Rector\Rules\UseToBeCamelCaseRector
1-expect(Str::camel($value) === $value)->toBeTrue();2+expect($value)->toBeCamelCase();
UseToBeDigitsRector
Converts ctype_digit() checks to toBeDigits() matcher
- class:
Pest\Rector\Rules\UseToBeDigitsRector
1-expect(ctype_digit($value))->toBeTrue();2+expect($value)->toBeDigits();
UseToBeDirectoryRector
Converts is_dir() checks to toBeDirectory() matcher
- class:
Pest\Rector\Rules\UseToBeDirectoryRector
1-expect(is_dir($path))->toBeTrue();2+expect($path)->toBeDirectory();
UseToBeEmptyRector
Converts empty checks and count-zero comparisons to toBeEmpty() matcher
- class:
Pest\Rector\Rules\UseToBeEmptyRector
1-expect(empty($value))->toBeTrue();2+expect($value)->toBeEmpty();
UseToBeFileRector
Converts is_file() checks to toBeFile() matcher
- class:
Pest\Rector\Rules\UseToBeFileRector
1-expect(is_file($path))->toBeTrue();2+expect($path)->toBeFile();
UseToBeInRector
Converts in_array() with value first to toBeIn() matcher
- class:
Pest\Rector\Rules\UseToBeInRector
1-expect(in_array($value, ['pending', 'active']))->toBeTrue();2+expect($value)->toBeIn(['pending', 'active']);
UseToBeInfiniteRector
Converts is_infinite() checks to toBeInfinite() matcher
- class:
Pest\Rector\Rules\UseToBeInfiniteRector
1-expect(is_infinite($value))->toBeTrue();2+expect($value)->toBeInfinite();
UseToBeJsonRector
Converts json_decode() null checks to toBeJson() matcher
- class:
Pest\Rector\Rules\UseToBeJsonRector
1-expect(json_decode($string) !== null)->toBeTrue();2+expect($string)->toBeJson();
UseToBeKebabCaseRector
Converts Str::kebab() equality checks to toBeKebabCase() matcher (requires illuminate/support)
- class:
Pest\Rector\Rules\UseToBeKebabCaseRector
1-expect(Str::kebab($value) === $value)->toBeTrue();2+expect($value)->toBeKebabCase();
UseToBeListRector
Converts array_is_list() checks to toBeList() matcher
- class:
Pest\Rector\Rules\UseToBeListRector
1-expect(array_is_list($array))->toBeTrue();2+expect($array)->toBeList();
UseToBeLowercaseRector
Converts strtolower() equality checks to toBeLowercase() matcher
- class:
Pest\Rector\Rules\UseToBeLowercaseRector
1-expect(strtolower($value) === $value)->toBeTrue();2+expect($value)->toBeLowercase();
UseToBeNanRector
Converts is_nan() checks to toBeNan() matcher
- class:
Pest\Rector\Rules\UseToBeNanRector
1-expect(is_nan($value))->toBeTrue();2+expect($value)->toBeNan();
UseToBeReadableWritableRector
Converts is_readable()/is_writable() checks to toBeReadable()/toBeWritable() matchers
- class:
Pest\Rector\Rules\UseToBeReadableWritableRector
1-expect(is_readable($path))->toBeTrue();2+expect($path)->toBeReadable();
UseToBeSlugRector
Converts Str::slug() equality checks to toBeSlug() matcher (requires illuminate/support)
- class:
Pest\Rector\Rules\UseToBeSlugRector
1-expect(Str::slug($value) === $value)->toBeTrue();2+expect($value)->toBeSlug();
UseToBeSnakeCaseRector
Converts Str::snake() equality checks to toBeSnakeCase() matcher (requires illuminate/support)
- class:
Pest\Rector\Rules\UseToBeSnakeCaseRector
1-expect(Str::snake($value) === $value)->toBeTrue();2+expect($value)->toBeSnakeCase();
UseToBeStudlyCaseRector
Converts Str::studly() equality checks to toBeStudlyCase() matcher (requires illuminate/support)
- class:
Pest\Rector\Rules\UseToBeStudlyCaseRector
1-expect(Str::studly($value) === $value)->toBeTrue();2+expect($value)->toBeStudlyCase();
UseToBeUppercaseRector
Converts strtoupper() equality checks to toBeUppercase() matcher
- class:
Pest\Rector\Rules\UseToBeUppercaseRector
1-expect(strtoupper($value) === $value)->toBeTrue();2+expect($value)->toBeUppercase();
UseToBeUrlRector
Converts filter_var($url, FILTER_VALIDATE_URL) checks to toBeUrl() matcher
- class:
Pest\Rector\Rules\UseToBeUrlRector
1-expect(filter_var($url, FILTER_VALIDATE_URL))->not->toBeFalse();2+expect($url)->toBeUrl();
UseToBeUuidRector
Converts UUID regex validation to toBeUuid() matcher
- class:
Pest\Rector\Rules\UseToBeUuidRector
1-expect(preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i', $value))->toBe(1);2+expect($value)->toBeUuid();
UseToContainEqualRector
Converts in_array(..., false) checks to toContainEqual() matcher
- class:
Pest\Rector\Rules\UseToContainEqualRector
1-expect(in_array($item, $array, false))->toBeTrue();2+expect($array)->toContainEqual($item);
UseToContainOnlyInstancesOfRector
Converts ->each->toBeInstanceOf() pattern to toContainOnlyInstancesOf() matcher
- class:
Pest\Rector\Rules\UseToContainOnlyInstancesOfRector
1-expect($items)->each->toBeInstanceOf(User::class);2+expect($items)->toContainOnlyInstancesOf(User::class);
UseToContainRector
Converts in_array() checks to toContain() matcher
- class:
Pest\Rector\Rules\UseToContainRector
1-expect(in_array($item, $array))->toBeTrue();2+expect($array)->toContain($item);
UseToEndWithRector
Converts str_ends_with() checks to toEndWith() matcher
- class:
Pest\Rector\Rules\UseToEndWithRector
1-expect(str_ends_with($string, 'World'))->toBeTrue();2+expect($string)->toEndWith('World');
UseToEqualCanonicalizingRector
Converts sort-then-compare to toEqualCanonicalizing() matcher
- class:
Pest\Rector\Rules\UseToEqualCanonicalizingRector
1-expect(sort($a))->toEqual(sort($b));2+expect($a)->toEqualCanonicalizing($b);
UseToEqualWithDeltaRector
Converts expect(abs($a - $b) < $delta)->toBeTrue() to expect($a)->toEqualWithDelta($b, $delta)
- class:
Pest\Rector\Rules\UseToEqualWithDeltaRector
1-expect(abs($a - $b) < 0.001)->toBeTrue();2+expect($a)->toEqualWithDelta($b, 0.001);
UseToHaveCountRector
Converts expect(count($arr))->toBe(5) to expect($arr)->toHaveCount(5)
- class:
Pest\Rector\Rules\UseToHaveCountRector
1-expect(count($array))->toBe(5);2+expect($array)->toHaveCount(5);
UseToHaveKeyRector
Converts array_key_exists() checks to toHaveKey() matcher
- class:
Pest\Rector\Rules\UseToHaveKeyRector
1-expect(array_key_exists('id', $array))->toBeTrue();2+expect($array)->toHaveKey('id');
UseToHaveKeysRector
Converts chained toHaveKey() calls to toHaveKeys() with array of keys
- class:
Pest\Rector\Rules\UseToHaveKeysRector
1-expect($array)->toHaveKey('id')->toHaveKey('name');2+expect($array)->toHaveKeys(['id', 'name']);
UseToHaveLengthRector
Converts strlen()/mb_strlen() comparisons to toHaveLength() matcher
- class:
Pest\Rector\Rules\UseToHaveLengthRector
1-expect(strlen($string))->toBe(10);2+expect($string)->toHaveLength(10);
UseToHavePropertiesRector
Converts chained toHaveProperty() calls to toHaveProperties() with array of properties
- class:
Pest\Rector\Rules\UseToHavePropertiesRector
1-expect($user)->toHaveProperty('name')->toHaveProperty('email');2+expect($user)->toHaveProperties(['name', 'email']);
UseToHavePropertyRector
Converts property_exists() checks to toHaveProperty() matcher
- class:
Pest\Rector\Rules\UseToHavePropertyRector
1-expect(property_exists($object, 'name'))->toBeTrue();2+expect($object)->toHaveProperty('name');
UseToHaveSameSizeRector
Converts expect(count($a))->toBe(count($b)) to expect($a)->toHaveSameSize($b)
- class:
Pest\Rector\Rules\UseToHaveSameSizeRector
1-expect(count($array1))->toBe(count($array2));2+expect($array1)->toHaveSameSize($array2);
UseToMatchArrayRector
Converts multiple array element assertions to toMatchArray() matcher
- class:
Pest\Rector\Rules\UseToMatchArrayRector
1-expect($array['name'])->toBe('Nuno');2-expect($array['email'])->toBe('nuno@example.com');3+expect($array)->toMatchArray(['name' => 'Nuno', 'email' => 'nuno@example.com']);
UseToMatchObjectRector
Converts consecutive toHaveProperty() with values to toMatchObject() matcher
- class:
Pest\Rector\Rules\UseToMatchObjectRector
1-expect($user)->toHaveProperty('name', 'Nuno');2-expect($user)->toHaveProperty('email', 'nuno@example.com');3+expect($user)->toMatchObject(['name' => 'Nuno', 'email' => 'nuno@example.com']);
UseToMatchRector
Converts expect(preg_match("/pattern/", $str))->toBe(1) to expect($str)->toMatch("/pattern/")
- class:
Pest\Rector\Rules\UseToMatchRector
1-expect(preg_match('/pattern/', $string))->toBe(1);2+expect($string)->toMatch('/pattern/');
UseToStartWithRector
Converts str_starts_with() checks to toStartWith() matcher
- class:
Pest\Rector\Rules\UseToStartWithRector
1-expect(str_starts_with($string, 'Hello'))->toBeTrue();2+expect($string)->toStartWith('Hello');
UseToThrowRector
Converts try/catch patterns in Pest tests to expect()->toThrow()
- class:
Pest\Rector\Rules\UseToThrowRector
1 test('it throws an error', function () {2- try {3- doSomething();4- } catch (RuntimeException $e) {5- expect($e->getMessage())->toBe('error');6- }7+ expect(fn () => doSomething())->toThrow(RuntimeException::class, 'error');8 });
UseTypeMatchersRector
Converts expect(is_array($x))->toBeTrue() to expect($x)->toBeArray()
- class:
Pest\Rector\Rules\UseTypeMatchersRector
1-expect(is_array($value))->toBeTrue();2+expect($value)->toBeArray();
UsesToExtendRector
Converts uses() and pest()->uses() to pest()->extend() for classes and pest()->use() for traits
- class:
Pest\Rector\Rules\Pest2ToPest3\UsesToExtendRector
1-uses(Tests\TestCase::class)->in('Feature');2+pest()->extend(Tests\TestCase::class)->in('Feature');
Now that you know how to automate refactoring your test suite, you may also be interested in type coverage to further improve your test code quality.