FlorianRappl / jest-fs-snapshot

Jest matcher for filesystem snapshotting.
http://npm.im/jest-fs-snapshot
MIT License
7 stars 1 forks source link

Store jest snapshots on the fs. #8

Open kevincox opened 3 years ago

kevincox commented 3 years ago

The package is quite useful but I find it somewhat annoying that it uses an archive format (and not a very common one). This makes it hard to review the snapshot changes. It would be great if the snapshots could actually be stored on the filesystem. This way it is easy to compare snapshots (probably using your VCS. This would quickly unlock a huge number of benefits.

This would be a breaking feature so would need to be behind a feature flag.

FlorianRappl commented 3 years ago

I think the original idea was to have binary stability. If you use the original format then a VCS like Git may modify the content (e.g., transform CRLF to LF), which may result in broken tests (the test target is usually not tracked by Git and thus will not be modified by Git).

We can still add this feature, but I would - as you suggested - put it behind a feature flag / options for the snapshot comparison.

kevincox commented 3 years ago

I guess that could be an option depending on the system. But at least on Linux files in git are just blobs so it shouldn't be an issue. However I would actually be surprised if this caused more issues because your Windows execution would write \r\n and you would diff it against the Linux \n and vice-versa. So I guess sometimes you want conversion on checkout and sometimes you don't 😅 However at least for my use case the FS would be ideal.

FlorianRappl commented 3 years ago

What I meant was that you can set the line endings in .gitattributes (locally or globally) and this will be respected when committing / checking out.

Since the diff would be on expanded files directly the Git internal storage wouldn't matter - only what has been checked out.