I have created a simple library for creating snapshot-tests
Please let me know what you think
The repository is available here.
If you are curious what snapshot testing is, you can check a simple explanation here.
If you want to see how it’s used, here is a project I am using it in (it’s a college-work, so nothing too serious) here.
This is because the name of the file is created from the test name. Adding support for multiple calls is absolutely the next step!
I was not aware of AssertValue. It looks really cool, to be honest. The difference I can see is that the assertion value is stored in the test itself, not in a separate file. It has its benefits and drawbacks. Another difference would be that AssertValue is interactive, whereas Snapshy is not. It’s not a good/bad thing, but a difference for sure.
I will explore AssertValue more. Thanks for sharing!
It can also be stored in a separate file with AssertValue, that’s just not the default method so as to make it obvious when looking at the test what value it should be, so it’s generally only recommended to use it for super larger values.
This is also optional. If interactivity is disabled (great for CI runners, via the environment) then on conflicts it reports and fails like a normal failing test.
Don’t stop yours though, there’s a lot of unexplored test-related space still!