jaredpalmer / cypress-image-snapshot

Catch visual regressions in Cypress
MIT License
887 stars 160 forks source link

Write snapshots to same directory regardless of running context #212

Open LucZwanenberg opened 3 years ago

LucZwanenberg commented 3 years ago

Suppose we have 2 feature files:

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?

pkerschbaum commented 2 years ago

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