Closed Ayc0 closed 7 months ago
We can use https://www.npmjs.com/package/node-exiftool to help with this (this library can read & write exif)
Edit: this library requires another one to be installed top level. So this is a no go.
What about https://github.com/hometlt/png-metadata or https://github.com/kujirahand/node-png-metadata? it's not really about exif data but other kind of metadata. It only works for PNG but jest-image-snapshot
also only supports them
If that's something we want to do, I can propose a PR
I look a bit into it, and manipulate EXIF can be tricky: there is plenty we can do and I don't think there is much we'd like to do from the jest-image-snapshot
point of view.
One thing we could do is expose a hook for just before writing a file to the FS:
type OnBeforeWriteToDisk = (arguments: {
buffer: Buffer; testPath: string; destination: string; /* others */
}) => Buffer
So that people could be free to do what they want with it, and while keeping the full control on how to write to disk
I opened https://github.com/americanexpress/jest-image-snapshot/pull/337 to solve this
At the moment, any test can generate any snapshot, and it's really hard to be able to find which test generated which image (as we can provide custom paths for the images, we cannot just rely on the path of the images, and also if we have 2 tests files in the same folder, images can be put in the same folder).
We could use EXIF data in images to store metadata in them (and we could also add the possibility in
.toMatchImageSnapshot()
to provide extra EXIF data if we want too), like the test suite (with the describe / it), the test path etc.