r-lib / testthat

An R 📦 to make testing 😀
https://testthat.r-lib.org
Other
869 stars 313 forks source link

Error in snapshot should work like error outside of snapshot #1906

Closed hadley closed 7 months ago

hadley commented 7 months ago
library(testthat)

test_that("abc", {
  local_edition(3)

  expect_snapshot(stop("foo!"))
  expect_snapshot(1 + 1)
})
#> Can't compare snapshot to reference when testing interactively.
#> ℹ Run `devtools::test()` or `testthat::test_file()` to see changes.
#> Current value:
#> Code
#>   1 + 1
#> Output
#>   [1] 2
#> ── Error: abc ──────────────────────────────────────────────────────────────────
#> `stop("foo!")` threw an unexpected error.
#> Message: foo!
#> Class:   simpleError/error/condition
#> Error:
#> ! Test failed

Created on 2023-11-28 with reprex v2.0.2.9000

Problems: