cypress-plugin-snapshots icon indicating copy to clipboard operation
cypress-plugin-snapshots copied to clipboard

(feat) Custom path / filename for snapshots

Open jonyw4 opened this issue 4 years ago • 2 comments

Hi guys, amazing plugin for cypress! It is really helpful. I need a feature in this project and I want to contribute 😁

Is your feature request related to a problem? Please describe. I have an automatically generated test file and I need to customize the snapshot path and filename.

Describe the solution you'd like Today if we use toMatchImageSnapshot we have name prop that defines a custom name for the image file. Maybe we could add that in toMatchSnapshot too. Is this way I can split the snapshot file into multiple files.

jonyw4 avatar Dec 28 '20 16:12 jonyw4

@meinaart Awesome plugin for cypress, thank youuuu. I wanted to ask if you have time, I want to contribute to your plugin and add some configuration to split the images into 3 folders (stable folder, actual folder, different folder). Could you tell us how to achieve this result? In which files do I need to change the paths and some conditions? Thanks in advance :))

adhamqodirov avatar Feb 04 '21 12:02 adhamqodirov

while looking for a different solution i found this workaround that seems to work well for this purpose-> https://github.com/meinaart/cypress-plugin-snapshots/issues/10#issuecomment-889470352

Just modify it so that fixCypressSpec accepts an argument and then splice that argument at lastIndexOf('/') or indexOf('.') in both absoluteFile and relativeFile.

sergei-shneider avatar Aug 15 '21 14:08 sergei-shneider