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 Snapshots

Pest Plugin Snapshots Laravel Package

spatie/pest-plugin-snapshots

Adds snapshot testing to Pest via Spatie’s snapshot assertions. Compare strings or JSON against stored snapshots with helper functions or Pest expectations. Ideal for stable output/regression testing in PHP projects.

View on GitHub
Deep Wiki
Context7

Add snapshot testing capabilities to Pest

Frequently asked questions about Pest Plugin Snapshots
How do I install spatie/pest-plugin-snapshots in my Laravel project?
Run `composer require spatie/pest-plugin-snapshots --dev` in your Laravel project. No additional Laravel-specific configuration is needed—it integrates seamlessly with Pest’s existing setup.
Does this package work with Pest v3 and Laravel 10?
Yes, the package explicitly supports Pest v2/v3 and Laravel 9/10+. The changelog confirms Pest v3 compatibility starting from version 2.2.0, so you’re covered for modern Laravel stacks.
Can I use snapshot testing for Livewire or InertiaJS components?
Absolutely. The package lets you test rendered Livewire or Inertia components directly with `expect($livewire->render())->toMatchSnapshot()` or similar assertions for JSON/API responses.
How do I handle dynamic data like timestamps in snapshots?
Use `assertMatchesJsonSnapshot()` with `ignoreKeys()` to exclude dynamic fields (e.g., timestamps). For example: `assertMatchesJsonSnapshot($response->json(), ignoreKeys: ['created_at'])`.
Will snapshot tests slow down my CI/CD pipeline?
Snapshot tests can add overhead, but they run efficiently in CI. Use the `--update-snapshots` flag sparingly (e.g., for intentional changes) and clean up unused snapshots with `.gitignore` or scripts.
Can I customize where snapshots are stored?
Yes, snapshots default to `tests/Snapshots/` but can be moved via the `SNAPSHOT_PATH` environment variable. This avoids conflicts with existing test structures.
What if my team isn’t familiar with snapshot testing?
Start with simple cases like API responses or HTML strings. Document common patterns (e.g., partial snapshots for APIs) and pair adoption with a workshop to ease the transition.
Does this package support testing PDFs or images?
Yes, since version 2.1.0, you can test binary outputs like PDFs or images using `toMatchImageSnapshot()`. This is ideal for Laravel apps generating dynamic visual content.
How do I update snapshots in CI without breaking tests?
Use the `--update-snapshots` flag during development or in CI for intentional changes. Review diffs in PRs to ensure updates are deliberate, then commit the new snapshots.
Are there alternatives to this package for Laravel/Pest?
If you’re not using Pest, you’d need `spatie/phpunit-snapshot-assertions` directly. For Pest users, this package is the most integrated option, offering a Pest-native API without PHPUnit migration.
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