Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Write snapshots to same directory regardless of running context #212

Open
LucZwanenberg opened this issue Aug 2, 2021 · 1 comment
Open

Comments

@LucZwanenberg
Copy link

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?

@pkerschbaum
Copy link

I think this is caused by a bug in Cypress itself: cypress-io/cypress#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:

const relativePath = path.relative(screenshotsFolder, screenshotDir);
const snapshotsDir = customSnapshotsDir
? path.join(process.cwd(), customSnapshotsDir, relativePath)
: path.join(screenshotsFolder, '..', 'snapshots', relativePath);

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants