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 Plugin Drift

Pest Plugin Drift Laravel Package

pestphp/pest-plugin-drift

Pest Plugin Drift adds drift detection to your Pest test suite, helping catch behavioral changes and flaky differences across runs. Install alongside Pest to track and report unexpected output or snapshot mismatches during testing.

View on GitHub
Deep Wiki
Context7

The Pest Drift Plugin

Frequently asked questions about Pest Plugin Drift
How does pest-plugin-drift help with Laravel API testing?
The plugin validates API responses against snapshots, ensuring consistency even as your Laravel backend evolves. For example, you can snapshot JSON responses from routes like `/api/users` and automatically detect drift if the structure or data changes unexpectedly. This is especially useful for contract testing in Laravel APIs.
Can I use pest-plugin-drift with Laravel’s built-in testing helpers?
Yes, the plugin integrates natively with Pest’s Laravel helpers like `actingAs()`, `followRedirects()`, and `assertJson()`. You can combine snapshot testing with traditional assertions, such as validating both the structure and content of API responses or rendered Blade views in Laravel.
What Laravel versions does pest-plugin-drift support?
The plugin is designed for modern Laravel versions (8.x and above) and works best with Pest 2.0+. It leverages Laravel’s testing utilities, so it’s compatible with any Laravel app using Pest as its testing framework. Check the Pest documentation for specific version requirements.
How do I configure snapshot storage for Laravel?
You can store snapshots in Laravel’s filesystem (e.g., `storage_path('app/snapshots')`) or external services like S3. The plugin supports custom storage backends, so you can integrate it with Laravel’s Filesystem abstraction or even a database table for centralized snapshot management.
Will pest-plugin-drift slow down my Laravel test suite?
Snapshot validation adds minimal overhead if used selectively. Exclude heavy tests (e.g., feature tests with database seeding) from snapshot checks, or use `.pestignore` to skip non-critical outputs like timestamps. For CI/CD, prioritize snapshot testing in critical paths like API endpoints.
How do I migrate from PHPUnit to Pest with drift testing?
Start by converting a subset of PHPUnit tests to Pest syntax, then adopt snapshots incrementally. For example, replace `$this->assertJson($response->getContent())` with `expect($response)->toBeJson()->snapshot()`. Use `pest --update-snapshots` to generate initial snapshots, then integrate drift checks into your CI pipeline.
Can I use pest-plugin-drift for database-driven Laravel tests?
Yes, but with caution. Snapshots work well for query results (serialized arrays) or API responses involving database data. Avoid snapshotting dynamic values like timestamps or UUIDs—use `.pestignore` to exclude them. For complex database tests, combine snapshots with Pest’s `expect()` assertions.
How does CI/CD handle snapshot updates in Laravel?
Configure your CI (GitHub Actions, GitLab CI) to auto-update snapshots on the `main` branch after approval, while blocking merges on drift failures in PRs. Use Laravel’s `storage_path()` for local snapshot storage or a cloud service like S3 for scalability. Tools like GitHub’s merge queues can streamline updates.
What if my Laravel team prefers PHPUnit over Pest?
If your team isn’t using Pest, consider a phased migration: start with Pest for new features or high-churn areas (e.g., API tests), then adopt drift testing there. The plugin’s snapshot features can later be extended to PHPUnit via custom assertions, though Pest provides tighter integration.
Are there alternatives to pest-plugin-drift for Laravel?
For snapshot testing, alternatives include PHPUnit’s `assertJsonStringEqualsJsonFile()` or custom tools like `spatie/laravel-snapshot-testing`. However, `pest-plugin-drift` offers deeper Pest integration, hybrid assertions (e.g., `expect()->toBeJson()->snapshot()`), and built-in CI/CD support tailored for Laravel’s testing workflow.
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.
hamzi/corewatch
minionfactory/raw-hydrator
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