Prior99 / jest-screenshot

A jest extension to deal with screenshots and all sorts of images.
MIT License
71 stars 21 forks source link

Allow modifying screenshot filename #71

Open mihkeleidast opened 3 years ago

mihkeleidast commented 3 years ago

Hello! I'm trying to evaluate if I can migrate from jest-image-snapshot to this library since this seems to run a lot faster.

Since I've got a lot of existing snapshots that I would rather not rename/update (so I wouldn't have to validate everything manually), I would like to change the name of the snapshots so I could use the same naming scheme as jest-image-snapshot uses. Additionally, we need to have the ability to change the filename based on some env variables, so a function would be good.

jest-image-snapshot allows doing this with the customSnapshotIdentifier option that can be a function. Would you consider adding something similar?

I tried doing this in my project by overriding the toMatchImageSnapshot with a custom matcher, but got stuck with the test count in the filename.

fjaeger commented 2 years ago

Allowing to provide a custom snapshot identifier would be awesome!