Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
hadley opened this issue Nov 28, 2023 · 0 comments · Fixed by #1910
Closed

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

hadley opened this issue Nov 28, 2023 · 0 comments · Fixed by #1910
Labels
feature a feature request or enhancement snapshot 📷
Milestone

Comments

@hadley
Copy link
Member

hadley commented Nov 28, 2023

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:

  • Don't get a traceback
  • Second snapshot is run
@hadley hadley added feature a feature request or enhancement expectation 🙀 snapshot 📷 and removed expectation 🙀 labels Nov 29, 2023
@hadley hadley added this to the v3.2.1 milestone Nov 29, 2023
hadley added a commit that referenced this issue Nov 29, 2023
hadley added a commit that referenced this issue Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement snapshot 📷
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant