Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Rector Pest Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Adoption of PestPHP as the primary testing framework for Laravel projects, replacing or migrating from PHPUnit. This package provides structured, automated migration paths (PEST_MIGRATION set) and version upgrades (UP_TO_PEST_40).
  • Improved test readability and maintainability by enforcing Pest’s expressive syntax (e.g., chaining expectations, matcher optimizations via PEST_CODE_QUALITY and PEST_CHAIN).
  • Laravel-specific optimizations (e.g., PEST_LARAVEL set for Str:: assertions) to reduce boilerplate and align with Laravel’s idioms.
  • Browser testing standardization (via PEST_BROWSER) for projects using pestphp/pest-plugin-browser, ensuring consistent assertion patterns.
  • Tech debt reduction by automating version upgrades (e.g., Pest v2→v4) and legacy PHPUnit→Pest migrations, accelerating refactoring efforts.
  • Build vs. Buy: Buy for teams already using Pest/Rector; build only if needing custom semantic rules beyond Pest’s ecosystem.

When to Consider This Package

  • Adopt if:

    • Your team uses PestPHP (or plans to migrate from PHPUnit) and wants to standardize test syntax or upgrade versions without manual refactoring.
    • You leverage Rector for PHP refactoring and seek Pest-specific optimizations (e.g., chaining, Laravel integrations).
    • Your project includes browser tests with pestphp/pest-plugin-browser and needs cleaner assertions.
    • You prioritize developer experience (DX) with self-documenting tests (e.g., Pest matchers over verbose expect()->toBe() chains).
  • Look elsewhere if:

    • You don’t use PestPHP (this is Pest-specific; PHPUnit users should explore rector/phpunit).
    • Your team prefers manual test refactoring or lacks Rector infrastructure.
    • You need custom semantic rules beyond Pest’s scope (e.g., framework-agnostic test optimizations).
    • Your project uses Pest < v2 (limited backward compatibility; check PEST_30/PEST_40 sets).
    • You require real-time linting (Rector is a batch tool; pair with PestStan for IDE feedback).

How to Pitch It (Stakeholders)

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:

  1. Migrate PHPUnit tests to Pest with one command (PEST_MIGRATION set).
  2. Upgrade Pest versions automatically (e.g., v2→v4) via UP_TO_PEST_40.
  3. Clean up tests with rules like:
    • Chaining expectations (expect($x)->toBe(1)->toBeInt()).
    • Pest matchers for Laravel (Str::equals()$expect($str)->toBeCaseInsensitive()).
    • Browser test optimizations (e.g., $page->assertValue() instead of expect($page->value())).
  4. Preview changes safely with --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."

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky