pestphp/pest
Pest is an elegant PHP testing framework focused on simplicity and a joyful developer experience. Write expressive tests with a clean syntax, run fast suites, and scale from tiny projects to large apps. Full docs at pestphp.com.
toHaveHttpStatus(), toBeAuthenticated()) that align with Laravel’s testing conventions. This eliminates the need for custom assertions or adapters, reducing technical debt.laravel, php) enables framework-agnostic reuse where needed.phpunit.xml with pest.php (optional) and update composer.json scripts.test() instead of public function test()).php preset for vanilla PHP, with assertions like toBeTrue(), toThrow(), or custom matchers.Symfony\Contracts\Cache\CacheInterface) and Lumen via Laravel presets.| Risk Area | Mitigation |
|---|---|
| Test Suite Migration | Pest provides a migration guide and --parallel mode to run PHPUnit and Pest tests concurrently during transition. |
| Browser Testing Stability | Playwright integration is battle-tested (used in Pest’s CI) but may require Docker/headless Chrome setup for CI environments. Monitor GitHub Issues. |
| Performance Overhead | Pest’s 30% faster boot times (v4.6.1) and time-based sharding reduce CI costs. Benchmark against PHPUnit using --update-shards to validate. |
| Long-Term Maintenance | MIT license, active development (weekly releases), and Nuno Maduro’s sponsorship model ensure sustainability. Risk of abandonment is low compared to niche alternatives. |
| Architecture Testing | Pest’s arch assertions (e.g., toUseTrait(), toExtend()) may require refactoring legacy code to enforce constraints. Pilot in a single module first. |
--parallel mode to co-run during migration.--flaky flag (v4.5.0) and test retries improve reliability.| Component | Compatibility | Notes |
|---|---|---|
| PHP Version | 8.1–8.5 (v4.1.4+) | Drop PHP 8.0 support if using v4.x. |
| Laravel | 10.x–12.x (v3.7.3+) | Pest v4 adds Laravel 12 support. For older versions, use v3.x. |
| Symfony | 6.x–8.x (v4.4.0+) | Supports Symfony components (e.g., CacheInterface) via presets. |
| PHPUnit | 11.5.x–12.5.x (v3.8.3–v4.2.0) | Pest bundles PHPUnit, so version conflicts are avoided. |
| Playwright | v1.40+ (for browser testing) | Requires Node.js 18+ and Playwright binaries. |
| CI Systems | GitHub Actions, CircleCI, TeamCity (v4.5.0), self-hosted | TeamCity support added in v4.5.0; validate with --teamcity flag. |
| Databases | MySQL, PostgreSQL, SQLite (via Laravel’s DB testing helpers) | Pest inherits Laravel’s DB testing capabilities (e.g., refreshDatabase()). |
| Queue Workers | Laravel Queues, Symfony Messenger | Use Pest’s actingAs() and queue() helpers for async testing. |
| Frontend Frameworks | React, Vue, Svelte (via Playwright) | Pest’s browser testing works with any framework; no PHP-specific limitations. |
Assessment Phase (1–2 weeks):
assertEquals, setUp()).--update-shards to quantify improvements.Pilot Migration (2–4 weeks):
phpunit.xml with pest.php and convert 1–2 test files.use (function () { ... }) to import Laravel helpers../vendor/bin/pest --parallel alongside PHPUnit to catch regressions.Full Migration (4–8 weeks):
test('description', fn() => ...).beforeEach(fn() => ...) for setup/teardown.--filter to incrementally migrate test files../vendor/bin/pest --parallel --shard={SHARD}.Optimization Phase:
--update-shards to balance CI load.--flaky to auto-retry unstable tests.--coverage --only-covered for focused reports.with() or dataset().Pest::group()How can I help you explore Laravel packages today?