Thanks for showing a good use of Jest Snapshots. Indeed, they can be misused, but they can also come in pretty handy at time. I've also used snapshot effectively when testing legacy code.
Here is another trick I have used successfully in the situation you describe. Very often when you have a format conversion function, you also have the inverse function (it would be the one converting from API to your internal representation). In this case, it can be handy to test the 2 together.
This way you can test many variations of data without having to resort to snapshot every time. Basically, you can skip snapshots when testing the fromAPIFormat function.
Thanks for showing a good use of Jest Snapshots. Indeed, they can be misused, but they can also come in pretty handy at time. I've also used snapshot effectively when testing legacy code.
Here is another trick I have used successfully in the situation you describe. Very often when you have a format conversion function, you also have the inverse function (it would be the one converting from API to your internal representation). In this case, it can be handy to test the 2 together.
This way you can test many variations of data without having to resort to snapshot every time. Basically, you can skip snapshots when testing the fromAPIFormat function.
Thanks for your post!
Very good point thanks for sharing!