Skip to content

Commit 46b255a

Browse files
authored
Merge pull request Codeception#280 from fkupper/patch-2
Update snapshot readme
2 parents 9b82770 + 61a6c81 commit 46b255a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

docs/09-Data.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,26 @@ On next execution the obtained data will be compared with previously saved snaps
366366
> To update a snapshot with a new data run tests in `--debug` mode.
367367

368368
By default Snapshot uses `assertEquals` assertion, however this can be customized by overriding `assertData` method.
369+
370+
### Failed assertion output
371+
372+
The assertion performed by `assertData` will not display the typical diff output from `assertEquals` or any customized failed assertion.
373+
To have the diff displayed when running tests, you can call the snapshot method `shouldShowDiffOnFail`:
374+
375+
{% highlight php %}
376+
377+
<?php
378+
public function testCategoriesAreTheSame(\AcceptanceTester $I, \Snapshot\Categories $snapshot)
379+
{
380+
$I->amOnPage('/categories');
381+
// I want to see the diff in case the snapshot data changes
382+
$snapshot->shouldShowDiffOnFail();
383+
$snapshot->assert();
384+
}
385+
386+
{% endhighlight %}
369387

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

371390
## Conclusion
372391

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

379398

380399
* **Next Chapter: [APITesting >](/docs/10-APITesting)**
381-
* **Previous Chapter: [< Customization](/docs/08-Customization)**
400+
* **Previous Chapter: [< Customization](/docs/08-Customization)**

0 commit comments

Comments
 (0)
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