Question: Compare dynamically fetched elements.
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:
-
git clone https://github.com/zwarag/poc-differ -
cd poc-differ -
yarn install -
npx cypress run - open https://github.com/zwarag/poc-differ/blob/master/cypress/e2e/screenshot.cy.js#L2 and uncomment the line.
-
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
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
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 30 days since being marked as stale.