What is snapshot testing? How can we use it to test the UI? How can it help us test quickly complex data structures or define a contract to an external system that we do not control?
{ assertSnapshot(add(3,5)) } • Record mode Saves a snapshot of the output as an artifact on disk e.g. testAddition1.txt • Verify mode Compares produced snapshot with saved reference snapshot
coverage than a unit test normally allows • A fast way to see how our view looks while developing • Immediately detect UI breaking changes and avoid regression bugs
essentially change detectors • Ideal when using external systems that we do not control • ..or when using external libraries that we want to update from time-to-time V2 V1 ✅ ✅ ✅ ✅
less about whether it is correct • Lock the behaviour to a golden master version • Low effort method that tests multiple properties at once using a single assertion WHEN WRITING CHARACTERISATION TESTS