Snapshot comparison never fails
See original GitHub issueI have been following the README step by step. Here is the state of my dummy project: Repo
I wrote this test: File
cy.visit("localhost:3000")
.document()
.toMatchImageSnapshot();
Running that test causes a screenshot to be saved. However, when I change what is rendered on the page, the tests still pass!
Expected result:
Actual result:
I do not understand why the tests pass, if what is rendered in cypress’ browser looks different than the screenshot that is saved.
I do not understand how toMatchImageSnapshot works. What is the base image that it uses? What is the current image?
Could someone please advise me how to get this test failing as expected?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:11
Top Results From Across the Web
Snapshot comparison - Virtuoso Guide
Snapshot comparison allows you to compare screenshots between previous and current versions of your application. It is useful for spotting ...
Read more >SQL Compare Snapshots: a lightweight database version ...
... SQL Compare Snapshots offer an easy way to work out what broke, if a change causes some tests to fail, as well...
Read more >Compare two localsnapshots in APFS | Apple Developer Forums
I found the compare verb in tmutil requires a snapshot path, but the localsnapshot is ... Not sure if you ever found an...
Read more >Isilon Quick Tips: Compare Snapshots - YouTube
DATA ENGINEER RESOURCE - Site devoted to "BUILDING STRONGER DATA ENGINEERS" ◅https://thomashenson.com▻ ASK BIG DATA BIG QUESTION - Submit ...
Read more >Isilon Quick Tips: Compare Snapshots in OneFS
Whatever the case OneFS has the ability to compare snapshots from ... to subscribe so that you never miss an episode of Isilon...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
[NOTE: My first message (I deleted to remove confusion) was incorrect due to forgotten testing code]
So guys (FYI @meinaart) …It bothered me so I digged deep down to the code and found the issue 😃
The problem is simple… we are using it wrong.
In documentation is writen simply
followed up by example
so it evokes we should put it directly to “toMatchImageSnapshot” function. But that is not correct.
in config.js is code which expects
so actually correct call to the method is:
cy.get('.class').toMatchImageSnapshot({imageConfig: {"threshold": 0})
and voala…it finally fails at not matching screenshots!
Nice find @wolfi3b, it also seems to fix it if there’s a value in your
cypress.json
file, like so:Side note, my instance would blow up unless I included
cypress-plugin-snapshots
in my config. I’m guessing the code for checking defaults isn’t quite right based on both of these issues.