meinaart / cypress-plugin-snapshots

Plugin for snapshot tests in Cypress.io
MIT License
489 stars 116 forks source link

(feat) Custom path / filename for snapshots #161

Open jonyw4 opened 3 years ago

jonyw4 commented 3 years ago

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.

adhamqodirov commented 3 years ago

@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 :))

sergei-shneider commented 2 years ago

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.