Snapshot Testing
Published 📅: ....
Last modified 📝: ....
Share this post on BlueskySee discussion on Bluesky
The other day I noticed this really succinct and to the point tweet about snapshot tests from Mark Dalgleish:
Just deleted all component snapshot tests from our React component library—in favour of @chromaui screenshot tests.
We were snapshotting component markup in isolation, outside of a browser, without styles. We weren't testing the output. We were testing implementation details. — Mark Dalgleish (@markdalgleish) February 25, 2019
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.
Tags:
Loading...