Skip to content

Update snapshot readme #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion docs/09-Data.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,26 @@ On next execution the obtained data will be compared with previously saved snaps
> To update a snapshot with a new data run tests in `--debug` mode.

By default Snapshot uses `assertEquals` assertion, however this can be customized by overriding `assertData` method.

### Failed assertion output

The assertion performed by `assertData` will not display the typical diff output from `assertEquals` or any customized failed assertion.
To have the diff displayed when running tests, you can call the snapshot method `shouldShowDiffOnFail`:

{% highlight php %}

<?php
public function testCategoriesAreTheSame(\AcceptanceTester $I, \Snapshot\Categories $snapshot)
{
$I->amOnPage('/categories');
// I want to see the diff in case the snapshot data changes
$snapshot->shouldShowDiffOnFail();
$snapshot->assert();
}

{% endhighlight %}

If ever needed, the diff output can also be omitted by calling `shouldShowDiffOnFail(false)`.

## Conclusion

Expand All @@ -378,4 +397,4 @@ to operate with database through a data abstraction layer, and use the DataFacto


* **Next Chapter: [APITesting >](/docs/10-APITesting)**
* **Previous Chapter: [< Customization](/docs/08-Customization)**
* **Previous Chapter: [< Customization](/docs/08-Customization)**
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy