Fixing snapshot testing fatigue
This is part of a series on Wicked Fast Testing, a testing style that represents tests as JSON data. Check out Part 1 for a quick introduction.
Snapshot testing as used in the Jest testing framework and Wicked Fast Testing can really speed our coding, but has a curse: snapshot fatigue. In this post, we’ll dig into snapshot testing, snapshot testing fatigue, and how you can use Wicked Fast Testing, but not Jest, to solve this problem.
Snapshot Testing
Snapshot testing involves capturing the output, say of a UI component, and persisting it. Then future tests are tested against this persisted output. The real advantage of snapshot testing is that the snapshots can be updated by the computer. Imagine changing a small UI component and breaking 100 tests. Without snapshot tests, a human slowly and manually updates each test. With snapshot tests, a computer rapidly and automatically updates each test.
In the Jest testing framework, we can update the snapshots with:
jest -u
In Wicked Fast Testing, …