Snapshy - an EXUnit library for writing snapshot tests

testing
exunit
snapshy
#1

Hello everyone!

I have created a simple library for creating snapshot-tests :camera_flash:
Please let me know what you think :wink:

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.

Have a nice day everyone :sunny:
Darek

2 Likes
#2

This looks interesting. :slight_smile:

Careful! There can only be one match_snapshot call per test macro call.

Why is this?


How does it compare to other libraries like AssertValue or so?

#3

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!

1 Like
#4

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. :slight_smile:

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! :slight_smile: