cypress-plugin-snapshots
cypress-plugin-snapshots copied to clipboard
(bug) Cannot compare snapshots in Runner
trafficstars
Describe the bug
I'm able to generate comparison screenshots thanks to #54, but when I click on <> COMPARE SNAPSHOT I just get the following in the dev tools console:
Unhandled rejection CypressError: Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
The command that returned the promise was:
> cy.readFile()
The cy command you invoked inside the promise was:
> cy.readFile()
Because Cypress commands are already promise-like, you don't need to wrap them or return your own promise.
Cypress will resolve your command with whatever the final Cypress command yields.
The reason this is an error instead of a warning is because Cypress internally queues commands serially whereas Promises execute as soon as they are invoked. Attempting to reconcile this would prevent Cypress from ever resolving.
https://on.cypress.io/returning-promise-and-commands-in-another-command
If I wait a little while I also get:
Unhandled rejection CypressError: Timed out retrying: cy.readFile("__snapshots__/cypress\integration\example.ts.snap") failed because the file does not exist at the following path:
<project root>\__snapshots__\cypress\integration\example.ts.snap
The second is interesting because my tests are only doing cy.document().toMatchImageSnapshot() and it appears to be using the project root instead of creating a folder alongside the spec file, unlike the image snapshots.
To Reproduce Steps to reproduce the behavior:
- Create a test (in this case in example.ts)
- Run it to generate snapshots
- Rotate the image (or another significant manipulation)
- Rerun the test
- Open Developer Tools and focus the Console
- Click on
<> COMPARE SNAPSHOTSin the test runner
Expected behavior The screenshot comparison dialog should pop up. Instead I see nothing unless the console is open.
Screenshots Can provide if required.
Desktop:
- OS: Windows 10 1909
- Cypress: 3.8.1
- Plugin: 1.2.9