Error condition provided by `expect_snapshot` seems buggy in 3.3.0
testthat::expect_snapshot(stop("error"), error = TRUE, cnd = TRUE)
── Snapshot ─────────────────────────────────────────────────────────────────────────────────────────
ℹ Can't save or compare to reference when testing interactively.
Code
stop("error")
Condition <rlang_error>
Error:
! error
─────────────────────────────────────────────────────────────────────────────────────────────────────
The condition seems changed to rlang_error in 3.3.0.
Found in pola-rs/r-polars#1642.
These are now converted to rlang errors in order to get tracebacks if your snapshot errors.
These are now converted to rlang errors in order to get tracebacks if your snapshot errors.
I see.
I would appreciate it if this was clearly stated in the news.
Alternatively, I'm wondering if it's possible to give the error a name that makes it immediately obvious that it has been replaced by testthat.
I'm a little confused (not unusual). What does the cnd_class argument now do that helps if it just replaces the class? I think the docs may need updating. Should we move back to expect_snapshot_error() if we want to check the class (to some degree) at the same time as well?
Hmmmm, let me see if I can somehow get the best of both worlds.
Hi @hadley
tidyterra is also broken in GH actions after this change. My use case was to Rbuildignore the folder tests/testthat/_snaps, as I performed a lot of tests that produced ggplots with rasters (Terra package).
These tests are really useful for me so I could capture lots of the changes introduced in ggplot2 >= 3.5.0, but increased the size of the package exceeding by far the CRAN size limit (hence I ignored them on built).
The approach worked fine and also it worked with testtthat::test_local(), but now this is broken in GH Actions.
tidyterra repo: https://github.com/dieghernan/tidyterra
@dieghernan I think that is another change in the latest testthat and not related to this issue. So I suppose you should create another issue.
https://github.com/r-lib/testthat/blob/bec8f61164a96803550e5aafc7305d323e8558de/NEWS.md?plain=1#L36
@dieghernan yes, please file a new issue.