Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spatie/pest-plugin-snapshots
Add snapshot testing capabilities to Pest
https://github.com/spatie/pest-plugin-snapshots
php snapshots testing
Last synced: 5 days ago
JSON representation
Add snapshot testing capabilities to Pest
- Host: GitHub
- URL: https://github.com/spatie/pest-plugin-snapshots
- Owner: spatie
- License: mit
- Created: 2020-05-18T19:11:27.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-20T14:13:25.000Z (5 months ago)
- Last Synced: 2024-09-20T15:18:48.387Z (5 months ago)
- Topics: php, snapshots, testing
- Language: PHP
- Homepage: https://pestphp.com
- Size: 54.7 KB
- Stars: 35
- Watchers: 5
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Snapshot Testing for Pest
[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/pest-plugin-snapshots.svg?style=flat-square)](https://packagist.org/packages/spatie/pest-plugin-snapshots)
[![run-tests](https://github.com/spatie/pest-plugin-snapshots/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/pest-plugin-snapshots/actions/workflows/run-tests.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/pest-plugin-snapshots.svg?style=flat-square)](https://packagist.org/packages/spatie/pest-plugin-snapshots)This package adds snapshot testing capabilities to **[Pest](https://pestphp.com)**. It wraps
our [phpunit-snapshot-assertions](https://github.com/spatie/phpunit-snapshot-assertions) package making
snapshot assertions available in Pest tests.## Support us
[
](https://spatie.be/github-ad-click/pest-plugin-snapshots)
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
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](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
## Installation
You can install the package via composer:
```bash
composer require spatie/pest-plugin-snapshots --dev
```## Usage
```php
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());
});
```You can also use an expectation:
```php
it('can be cast to string', function () {
$order = new Order(1);expect($order->toString())->toMatchSnapshot();
});
```For the full list of assertions, please refer to underlying package: [phpunit-snapshot-assertions](https://github.com/spatie/phpunit-snapshot-assertions).
## Testing
``` bash
composer test
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
## Security
If you've found a bug regarding security please mail [[email protected]](mailto:[email protected]) instead of using the issue tracker.
## Credits
- [Nuno Maduro](https://github.com/nunomaduro)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.