Skip to content

Commit c808c9a

Browse files
authored
Explain the deal w/ expect_snapshot_error() vs. expect_snapshot(error = TRUE) (#1616)
1 parent 9868764 commit c808c9a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

vignettes/snapshotting.Rmd

+2
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ test_that("you can't add weird thngs", {
214214

215215
`expect_snapshot()` is the most used snapshot function because it records everything: the code you run, printed output, messages, warnings, and errors.
216216
But sometimes you just want to capture the output or errors in which you might want to use `expect_snapshot_output()` or `expect_snapshot_error()`.
217+
This can happen when the associated code is lengthy or doesn't add much in terms of capturing the test's intent.
218+
`expect_snapshot_error()` predates `expect_snapshot()` and, if history had unfolded differently, `expect_snapshot(error = TRUE, ...)` probably would have made `expect_snapshot_error()` unnecessary.
217219

218220
Or rather than caring about side-effects, you may want to check that the value of an R object stays the same.
219221
In this case, you can use `expect_snapshot_value()` which offers a number of serialisation approaches that provide a tradeoff between accuracy and human readability.

0 commit comments

Comments
 (0)