Allow customizing snapshot subdirectory #158
Closed
+71
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Basically, this change is a workaround for #61.
Because of the existing behavior of Cypress,
cy.screenshot
in the Interactive mode puts screenshots in different subdirectories. If you run all specs the screenshot will be nested in 'All Specs' folder, whilst if you run the only spec file, the screenshot will be under the folder of a spec file name.As this plugin works on top of cypress screenshots but uses its own folder to store snapshots (basically it copy/pastes screenshots to snapshots folder), one of the possible workarounds is to modify the subdirectory of every snapshot. To make it possible, we can pass a callback to plugin options like that:
If we return an empty string from
getSpecSnapshotFolder
, that effectively means that no subdirectory needed and all snapshots will be stored in the root of the snapshots folder. Not sure, what happens with spec names collisions though...