laravel-pest-rector

Refactors Pest 5 test assertions into Pest matchers using the Rector plugin.

3|Updated Apr 11, 2026
One-click install
npx skills add https://github.com/bravros/bravros --skill laravel-pest-rector-bravros
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: laravel-pest-rector
Source: https://github.com/bravros/bravros/tree/main/plugins/tools/skills/laravel-pest-rector
Command: npx skills add https://github.com/bravros/bravros --skill laravel-pest-rector-bravros

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pestphp/pest-plugin-rector, rector/rector, and includes references (resource) components.

What problem does it solve? Manually converting raw assertions like expect(count($array))->toBe(5) into idiomatic Pest matchers across a large test suite is tedious and error-prone, and running Rector without the right configuration silently rewrites application code instead of tests. ## Core Features & Use Cases - Automated matcher conversion: Applies the 60-rule PestSetList::CODING_STYLE set to rewrite assertions into matchers like toHaveCount and toHaveKey, scoped strictly to tests/. - Generated-config trap prevention: Forces writing rector.php before any Rector invocation, since Rector auto-generates an app-wide config on non-TTY shells that performs zero Pest refactoring. - Dry-run gated workflow: Requires a green --no-tia baseline, a reviewed --dry-run diff, Pint formatting, and a post-run regression check before committing. - Use Case: After upgrading a Laravel project to Pest 5, run this skill to modernize thousands of existing Pest tests into chained matcher syntax with a verifiable, test-only blast radius. ## Quick Start Ask the agent to run the laravel-pest-rector workflow to refactor the tests directory into Pest matchers with a dry-run preview first.

Frequently Asked Questions about laravel-pest-rector

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert Pest assertions to Pest matchers automatically?▼

Install pestphp/pest-plugin-rector, write a rector.php that scopes withPaths to tests/ and registers PestSetList::CODING_STYLE, then run vendor/bin/rector process --dry-run to review before applying. The plugin's 60 rules rewrite raw assertions into matchers like toHaveCount and toHaveKey.

Does pest-plugin-rector convert PHPUnit tests to Pest?▼

No, pest-plugin-rector only refactors tests that are already written in Pest syntax. Converting PHPUnit class-style tests to Pest is the job of pest-plugin-drift, which must run before this refactoring step.

Why did Rector rewrite my app code instead of my tests?▼

Rector auto-generates a rector.php when none exists, and on a non-TTY shell the prompt auto-accepts. That generated config targets the whole application with no Pest set, so it applies generic rules to app code while performing zero Pest matcher conversions.

Why does rector --dry-run exit with a non-zero code?▼

Rector's --dry-run exits with CHANGED_CODE when it finds changes to make, which is the success case for a preview. Never gate on the exit code alone; read the diff to confirm paths stay under tests/ and changes are matcher conversions.

What are the prerequisites for using the Pest Rector plugin?▼

You need Pest 5 installed and a fully green, unfiltered test suite run with --no-tia as a baseline. The working tree must be clean before applying, since Rector rewrites files in place with no backup and the git diff is the only undo.