Day 15: Snapshot Testing with testthat
Test complex outputs that are hard to specify exactly.
Text snapshots:
test_that("error messages are informative", {
expect_snapshot(my_function(bad_input), error = TRUE)
})
Pro Tip: Review snapshot changes carefully - they capture everything, including whitespace and formatting.
2 media