meinaart / cypress-plugin-snapshots

Plugin for snapshot tests in Cypress.io
MIT License
497 stars 117 forks source link

(bug) Cannot compare snapshots in Runner #88

Open StormPooper opened 4 years ago

StormPooper commented 4 years ago

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:

  1. Create a test (in this case in example.ts)
  2. Run it to generate snapshots
  3. Rotate the image (or another significant manipulation)
  4. Rerun the test
  5. Open Developer Tools and focus the Console
  6. Click on <> COMPARE SNAPSHOTS in 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: