cypress-image-diff icon indicating copy to clipboard operation
cypress-image-diff copied to clipboard

Question: Compare dynamically fetched elements.

Open zwarag opened this issue 3 years ago • 1 comments

I was wondering if there is a way to compare elements of a page that need to be fetched at runtime. Currently I've experiencing the problem that the test immediately stops running after one of those elements differs from the previous screenshot. However I would like it to keep running the test, even if it partially fails, so that all screenshots are generated.

Example:

  1. git clone https://github.com/zwarag/poc-differ
  2. cd poc-differ
  3. yarn install
  4. npx cypress run
  5. open https://github.com/zwarag/poc-differ/blob/master/cypress/e2e/screenshot.cy.js#L2 and uncomment the line.
  6. npx cypress run

Expected behaviour: ✅ The first npx cypress run creates 26 screenshots in poc-differ/cypress-visual-screenshots/baseline ❌ The second npx cypress run creates 26 screenshots in poc-differ/cypress-visual-screenshots/diff

Current behaviour: The first npx cypress run creates 26 screenshots in poc-differ/cypress-visual-screenshots/baseline The second npx cypress run creates 1 screenshots in poc-differ/cypress-visual-screenshots/diff

zwarag avatar Sep 08 '22 08:09 zwarag

The function compareSnapshot functions as an expect statement, which fails the test immediately if the comparison fails, which is usually desirable to save time. I don't think this package provides this functionality, but you might be able to split the "take screenshot" action from the "compare screenshots" action by writing your own command. For reference, here's how the compareSnapshot command works: https://github.com/uktrade/cypress-image-diff/blob/main/src/command.js

nmkataoka avatar Sep 23 '22 16:09 nmkataoka

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Sep 17 '23 01:09 github-actions[bot]

This issue was closed because it has been inactive for 30 days since being marked as stale.

github-actions[bot] avatar Oct 18 '23 01:10 github-actions[bot]