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

Pest Laravel Package

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.

View on GitHub
Deep Wiki
Context7

The elegant PHP Testing Framework.

Frequently asked questions about Pest
Can Pest fully replace PHPUnit in a Laravel 11+ project?
Yes, Pest is a drop-in replacement for PHPUnit in Laravel 11+. It uses the same test file structure (`.php`) but offers a cleaner, expressive syntax. The `pest` CLI replaces `phpunit`, and Laravel’s built-in testing helpers (like `actingAs()` or `get()`) work out of the box. No configuration changes are needed for basic tests.
How does Pest’s syntax compare to PHPUnit for Laravel tests?
Pest uses a more readable, DSL-like syntax (e.g., `expect($user)->toBeAuthenticated()` instead of `assertTrue(auth()->check())`). It retains PHPUnit’s power but simplifies common Laravel testing patterns, like HTTP assertions (`get('/dashboard')->assertOk()`). The learning curve is minimal, especially for teams already using Laravel’s testing helpers.
Does Pest support browser testing (e.g., Playwright) in Laravel?
Yes, Pest v4+ includes built-in Playwright integration for end-to-end testing. Use `BrowserTestCase` to write tests like `it('logs in', fn () => $page->click('button[type=submit]'))`. Playwright runs in PHP, eliminating the need for JavaScript-based tools like Cypress. Requires Node.js and Playwright binaries, but setup is straightforward via Pest’s docs.
What Laravel versions does Pest officially support?
Pest is fully compatible with Laravel 8+, including Laravel 11 (where it’s the default testing framework). For older versions (Laravel 7/8), use Pest v3.x or v4.x with the `laravel` preset. Pest leverages Laravel’s service container and testing helpers, so it integrates tightly with all modern Laravel features like routes, queues, and notifications.
How do I migrate a large PHPUnit test suite to Pest?
Start by auditing your test suite for PHPUnit-specific features (e.g., `@dataProvider`, `getMockBuilder()`), which may need refactoring. Pest provides a [migration guide](https://pestphp.com/docs/migration) and a compatibility layer for gradual adoption. For large suites, prioritize converting tests by feature, using `pest --parallel` to validate performance early. Pest’s syntax is intuitive, so most tests convert in hours.
Can Pest run tests in parallel for faster CI/CD pipelines?
Absolutely. Pest supports parallel test execution via the `--parallel` flag, which splits tests across processes. For Pest v4.6+, time-based sharding further optimizes CI runtime by distributing tests dynamically. This can reduce test suite execution time by 30–50%, especially for large projects. Configure it in your CI (e.g., GitHub Actions) with minimal setup.
Are there any gotchas when using Pest with Laravel’s authentication?
No gotchas—Pest seamlessly integrates with Laravel’s authentication system. Use `actingAs($user)` or `toBeAuthenticated()` assertions just like in PHPUnit. Pest also supports testing session-based auth (e.g., `toHaveSession(['key' => 'value'])`). For API tests, Pest’s HTTP helpers (`post('/login')`) work identically to Laravel’s built-in testing tools.
Does Pest work outside Laravel (e.g., vanilla PHP or Symfony)?
Pest primarily targets Laravel but includes presets for vanilla PHP (`php` preset) and Symfony 8+ (v4.4+). While it lacks Laravel-specific helpers outside Laravel apps, its core testing features (expectations, assertions, parallel runs) work universally. For Symfony, use the `symfony` preset, but some Laravel integrations (e.g., `actingAs()`) won’t apply.
How does Pest handle database transactions in tests?
Pest inherits Laravel’s transaction management by default—each test runs in a fresh database transaction. Use `uses(DatabaseTransactions::class)` in your test file to enable it. For performance, Pest supports `DatabaseMigrations` to refresh the schema between test suites. This matches PHPUnit’s behavior but with a cleaner syntax (e.g., `uses(RefreshDatabase::class)`).
What’s the best way to debug failing Pest tests in Laravel?
Use Pest’s built-in debugging tools like `dd()` or `dump()` in assertions. For HTTP tests, inspect responses with `->assertSee()` or `->assertJson()`. Pest integrates with Laravel’s debug tools (e.g., `php artisan tinker`) and IDEs (PHPStorm/VSCode) for step-through debugging. For Playwright tests, use Playwright’s DevTools (`$page->pause()`) to inspect browser state interactively.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai