Jakub Sobolewski drills into a particular form of testing:
Snapshot testing is not about screenshots.
Most people meet it through UI regression tests: render a component, save a picture, fail the build when the picture changes. So the technique gets filed away as “the thing that compares images.” That is one use. But not the only one.
The mechanic underneath is general. Capture some output, save it to a file, and on every later run compare fresh output against the saved copy. The output can be a plot. It can also be console text, a log, a data frame, an error message, or a deeply nested list. Anything you can serialize, you can snapshot.
Read on to see how you can perform snapshot testing, using examples in R to demonstrate. H/T R-Bloggers.
Leave a Comment