Snapshot Testing for Pest
This package adds snapshot testing capabilities to Pest. It wraps our phpunit-snapshot-assertions package making snapshot assertions available in Pest tests.
Support us
Learn how to create a package like this one, by watching our premium video course:
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Installation
You can install the package via composer:
composer require spatie/pest-plugin-snapshots --devUsage
use function Spatie\Snapshots\{assertMatchesSnapshot, assertMatchesJsonSnapshot};
it('can be cast to string', function () {
$order = new Order(1);
assertMatchesSnapshot($order->toString());
});
it('can be cast to json', function () {
$order = new Order(1);
assertMatchesJsonSnapshot($order->toJson());
});For the full list of assertions, please refer to underlying package: phpunit-snapshot-assertions.
Testing
composer testChangelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

