-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Snapshots for running all specs don't use individual spec snapshots #61
Comments
Yikes, this looks related to:
This bug basically makes snapshot testing "All Tests" in interactive mode useless and is also difficult to workaround since I think ideally it would be fixed in cypress-io/cypress#1586 but it doesn't look like that has been worked on yet. I'm open to finding ways of getting around this in the meantime. |
What about adding an optional flag to the configuration, to change the snapshots output directory structure to a flat one?! The default file names could still be named after test suite name + test name, but all images will be stored on one level (in one output directory). Independent from the run-mode. |
There's this workaround: meinaart/cypress-plugin-snapshots#10 (comment) Has anyone else tried it with |
Yeh, it's not working for me either :( |
Looks like a proper fix for that issue will be possible when cypress-io/cypress#1586 is addressed. In the meanwhile, we could use the following workaround #158. @jaredpalmer what do you think about that workaround? |
I have a new workaround for this, based on #158. The workaround is to set the
And that's it! Also, in our tests, we make sure to give a name to the image snapshots to make them unique. Here's the diff for the patch: diff --git a/node_modules/cypress-image-snapshot/plugin.js b/node_modules/cypress-image-snapshot/plugin.js
index 106d726..4ca37b5 100644
--- a/node_modules/cypress-image-snapshot/plugin.js
+++ b/node_modules/cypress-image-snapshot/plugin.js
@@ -96,7 +96,9 @@ function matchImageSnapshotPlugin({ path: screenshotPath }) {
// remove the cypress v5+ native retries suffix from the file name
const snapshotIdentifier = name.replace(/ \(attempt [0-9]+\)/, '');
- const relativePath = _path2.default.relative(screenshotsFolder, screenshotDir);
+ // always write snapshot images to root snapshots directory
+ // this is a workaround for https://github.com/jaredpalmer/cypress-image-snapshot/issues/61
+ const relativePath = "";
const snapshotsDir = customSnapshotsDir ? _path2.default.join(process.cwd(), customSnapshotsDir, relativePath) : _path2.default.join(screenshotsFolder, '..', 'snapshots', relativePath);
const snapshotKebabPath = _path2.default.join(snapshotsDir, `${snapshotIdentifier}${kebabSnap}`); |
I there a way to have this issue patched in this repo through an option? |
Hi!
I haven't had a chance to investigate this super deeply.
But if you run all the tests specs together from the
cypress open
ui -cypress-image-snapshot
is generating snapshots under anAll Specs
folder, rather than using the snapshots stored under each respective spec's folder.From a quick glance in the code this isn't intentional, and I can see a related issue:
#17
Is it possible that the same issue is reoffending in later versions?
Versions:
Cypress: 3.1.2
cypress-image-snapshot: 2.3.5
The text was updated successfully, but these errors were encountered: