Matt Hamlin's Blog

moon indicating dark mode
sun indicating light mode

Snapshot Testing

March 01, 2019

The other day I noticed this really succinct and to the point tweet about snapshot tests from Mark Dalgleish:

The valuable insight here being the following:

We were snapshotting component markup in isolation, outside of a browser, without styles. We weren't testing the output. We were testing implementation details.

When I started working with Jest and snapshot testing I thought it was one of the coolest things ever. It felt like I was adding meaningful code coverage to my code, when in reality I was only testing the implementation details of it.

Over time I started to realize that the tests I was adding were only adding more friction to the work I was doing. Since then I have been slowly removing snapshot tests from my code whenever I make a change that causes the snapshot tests to fail.