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

Phpunit Snapshot Assertions Laravel Package

spatie/phpunit-snapshot-assertions

Add snapshot testing to PHPUnit. Assert strings, JSON, arrays, and objects against saved snapshots; first run writes snapshots, later runs compare and fail on regressions. Simple trait-based API (e.g., assertMatchesJsonSnapshot) for PHP and Laravel projects.

View on GitHub
Deep Wiki
Context7
5.4.0

What's Changed

  • Add vendor/bin/update-snapshots wrapper binary that sets UPDATE_SNAPSHOTS=true and runs PHPUnit. This replaces the previously documented phpunit -d --update-snapshots syntax, which abused PHPUnit's -d flag and produces a Failed to set "--update-snapshots=1" test runner warning since PHPUnit 12.5.12.
  • Drop the phpunit -d --without-creating-snapshots form from the README. Use the CREATE_SNAPSHOTS=false environment variable instead. The argv check is kept in shouldCreateSnapshots() for backwards compatibility.
  • The wrapper restores the prior UPDATE_SNAPSHOTS env var state on shutdown, so it does not leak a state mutation to any in-process code that runs after PHPUnit.
  • Reworded the "Snapshot does not exist" failure message and the "snapshots can be updated by..." prompt to point at the new approach.
  • shouldUpdateSnapshots() and shouldCreateSnapshots() now check the env var first, then fall back to the legacy CLI argument.
  • Fix tests on PHPUnit 12.5+, where mocks throwing AssertionFailedError are tracked as a test failure even when user code catches the exception. The expectFail helper now uses a plain RuntimeException carrying the expected message.

Closes #242.

Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.3.2...5.4.0

5.3.2

What's Changed

  • Fix BC break in getSnapshotId() from named snapshots feature — restored original no-parameter signature
  • Add README documentation for named snapshots

Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.3.1...5.3.2

5.3.1

What's Changed

  • Allow PHPUnit 13
5.3.0

What's Changed

Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.2.3...5.3.0

5.2.2

What's Changed

Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.2.1...5.2.2

5.2.1

What's Changed

New Contributors

Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.2.0...5.2.1

5.1.1
  • fix image driver
5.0.2
5.0.1
4.2.12

What's Changed

New Contributors

Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/4.2.11...4.2.12

4.2.9

What's Changed

New Contributors

Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/4.2.8...4.2.9

4.2.7
  • clean filenames on MatchesFileSnapshot for Windows (#130)
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