mrpunyapal/rector-pest
Rector rules for migrating PHP tests to Pest. Automates converting PHPUnit-style tests and assertions into Pest’s fluent syntax, helping you modernize test suites quickly and consistently with minimal manual edits.
PEST_MIGRATION set) and version upgrades (UP_TO_PEST_40).PEST_CODE_QUALITY and PEST_CHAIN).PEST_LARAVEL set for Str:: assertions) to reduce boilerplate and align with Laravel’s idioms.PEST_BROWSER) for projects using pestphp/pest-plugin-browser, ensuring consistent assertion patterns.Adopt if:
pestphp/pest-plugin-browser and needs cleaner assertions.expect()->toBe() chains).Look elsewhere if:
rector/phpunit).PEST_30/PEST_40 sets).For Executives:
"This package automates PestPHP test modernization—reducing manual refactoring time by 70%+ for migrations (PHPUnit→Pest) and version upgrades (v2→v4). It enforces best practices like chained expectations and Laravel-specific optimizations, improving test readability and maintainability. For example, converting 100 verbose expect() calls into 20 chained assertions cuts cognitive load and speeds up debugging. Low-risk (MIT license, MIT-backed maintainer) and integrates seamlessly with our existing Rector workflows."
For Engineers: *"Rector Pest lets us:
PEST_MIGRATION set).UP_TO_PEST_40.expect($x)->toBe(1)->toBeInt()).Str::equals() → $expect($str)->toBeCaseInsensitive()).$page->assertValue() instead of expect($page->value())).--dry-run before applying.
Requires Rector 2.0+ and PHP 8.2+; zero runtime overhead."*For QA/DevOps:
"This reduces flaky tests by standardizing assertion patterns (e.g., Pest’s toThrow() over PHPUnit’s expectException()). The PEST_CODE_QUALITY set also catches anti-patterns like redundant type checks, improving test reliability. Pair with PestStan for real-time validation."
How can I help you explore Laravel packages today?