Prior99 / jest-screenshot

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

Possibility to add a custom name #2

Closed Jack89ita closed 6 years ago

Jack89ita commented 6 years ago

Hi! First of all thank you for this amazing plugin. I would like to know if there's a option to change the default name of the generated .png file. Can you help me? Thanks

Prior99 commented 6 years ago

Hi. Currently there isn't. What is your usecase?

Jack89ita commented 6 years ago

Well actually i've got 2 arrays: 1 for a set of devices and 1 for a set of urls. So it would be much clear for me to name the generated file with those array indexes (eg: desktop_agency_test.png, mobile_agency_test.png). Or even better change folder name (eg: desktop/agency_test.png, mobile/agency_test.png). Is it worth it? Thanks

Jack89ita commented 6 years ago

It would be perfect, in that way i can dynamically change my path for every file! Thank you!

Prior99 commented 6 years ago

It is possible to configure the folder name for all images, but not individually. I could add the option to provide a configuration object to .toMatchImageSnapshot() like this:

expect(...).toMatchImageSnapshot({ path: "path/to/file.png" })

would that suit your needs?

Prior99 commented 6 years ago

I'll see whether I can manage to do this today or tomorrow. Of course I'd also welcome a pull request :)

Jack89ita commented 6 years ago

Ok thank you. Let me know when is done!

Prior99 commented 6 years ago

Implemented and published in 0.2.0.