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

Write snapshots to same directory regardless of running context

Open LucZwanenberg opened this issue 4 years ago • 1 comments

Suppose we have 2 feature files:

  • A.feature
  • B.feature

When we run all specs in the Cypress GUI using the button "Run 2 integration spes", then the snapshots will be written to the directory "cypress/reports/All Integration Specs". When we run A.feature in isolation, then a new snapshot will be written to "cypress/reports/A.feature".

Is there a way to always use the same snapshot regardless of whether we're running all tests or a single test in isolation? Similar to how snapshot testing works in Jest?

LucZwanenberg avatar Aug 02 '21 11:08 LucZwanenberg

I think this is caused by a bug in Cypress itself: https://github.com/cypress-io/cypress/issues/3090.

The screenshot directory reported by Cypress to cypress-image-snapshot (screenshotDir) is used by cypress-image-snapshot internally to compute the final destination of the image snapshot: https://github.com/jaredpalmer/cypress-image-snapshot/blob/0510252bc5f192c410bcca45b511f07737bce4a2/src/plugin.js#L79-L82

patricktree avatar Nov 17 '21 00:11 patricktree