cypress-image-snapshot: snapshots recorded during `cypress run` mismatch `cypress open`
To reproduce:
- write in a test
cy.matchImageSnapshot()
- run
$ node_modules/.bin/cypress run
- run again
$ node_modules/.bin/cypress run
- test passes - run
$ node_modules/.bin/cypress open
- click on the aforementioned test - test fails
Starting with cypress open
and then following with cypress run
also gives an error.
This might be a bug/inconsistency on cypress
’s end, so let me know if I should open it there as well.
Many thanks for this awesome tool!
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 12
- Comments: 15
I would refer to this issue in Cypress for this one: https://github.com/cypress-io/cypress/issues/3324
Cypress’s current recommendation is to only take screenshots for comparison during
cypress run
. There’s further explanation here: https://github.com/cypress-io/cypress/issues/3324#issuecomment-542414532You could write logic to disable screenshotting during
cypress open
by using theisInteractive
config option or browser.isHeadless option. https://docs.cypress.io/api/cypress-api/browser.html#Screenshot-only-in-headless-browserMy workaround is to only capture images in headless mode.
I get the same issue.
cypress.json
commands.js
When I run tests in cypress open I get a snapshot resolution of 1400x600. When I run in cypress run I get a snapshot of 1280x660
One strange behaviour is that if i remove the viewport config from cypress.json i get a snapshot of 1000x660, which is the default viewport.
If i change cypress.json to
Then recorded snapshot in cypress run mode changes to 1280x650, so i reacts to viewportHeight but not to viewportWidth.
If you have a custom viewport setting, viewportWidth defaults to 1280.
Trying to overwrite
matchImageSnapshot
, I got the error:Overwriting
screenshot
I got the error:Asserted the headed vs headless mode seem to work but looks clumsy:
I ran it in gitlab ci, and there’s a mismatch between the images taken by the ci and taken locally, with the same cypress command
cypress run
Seems like
cypress run
only takes screenshot of the visible screen, andcypress open
scrolls and screenshots the entire pageI recorded now using
cypress open
and then didcypress run
and this is the error:Error: Image size (360x640) different than saved snapshot size (360x3566).