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.
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.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.UPDATE_SNAPSHOTS env var state on shutdown, so it does not leak a state mutation to any in-process code that runs after PHPUnit.shouldUpdateSnapshots() and shouldCreateSnapshots() now check the env var first, then fall back to the legacy CLI argument.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
getSnapshotId() from named snapshots feature — restored original no-parameter signatureFull Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.2.3...5.3.0
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.2.2...5.2.3
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.2.1...5.2.2
assertMatchesJsonSnapshot to accept any JSON-serializable value by @LuckyWindsck in https://github.com/spatie/phpunit-snapshot-assertions/pull/216Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.2.0...5.2.1
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.1.8...5.2.0
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.1.7...5.1.8
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.1.6...5.1.7
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.1.5...5.1.6
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/4.2.16...4.2.17
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.1.4...5.1.5
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.1.3...5.1.4
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.1.2...5.1.3
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.1.1...5.1.2
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.0.2...5.1.0
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/5.0.0...5.0.1
run-tests status in README.md by @gomzyakov in https://github.com/spatie/phpunit-snapshot-assertions/pull/160Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/4.2.16...5.0.0
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/4.2.15...4.2.16
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/4.2.14...4.2.15
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/4.2.13...4.2.14
Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/4.2.12...4.2.13
LIBXML_HTML_NODEFDTD to maintain output consistency by @JayBizzle in https://github.com/spatie/phpunit-snapshot-assertions/pull/141Full Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/4.2.11...4.2.12
--without-creating-snapshots flagSnapshots generated with assertMatchesSnapshot will break when upgrading to this version. The easiest way to upgrade is to ensure your snapshot tests pass, delete your snapshots, upgrade the package, then rerun the tests to generate new snapshots.
assertMatchesSnapshot: scalars (strings, integers & floats) are serialized to txt files, objects & arrays are serialized to yaml filesTextDriver to store snapshots in txt filesObjectDriver to serialize data to YAML and store snapshots in yaml filesVarDriverassertMatchesJsonSnapshot now supports all JSON serializable objects, and won't convert empty arrays to obejcts anymoreassertMatchesHtmlSnapshot assertionassertMatchesFileSnapshotassertMatchesFileHashSnapshotassertMatchesFileHashSnapshot assertionexample folder to .gitattributesFull Changelog: https://github.com/spatie/phpunit-snapshot-assertions/compare/4.2.7...4.2.8
How can I help you explore Laravel packages today?