-
Notifications
You must be signed in to change notification settings - Fork 340
Closed
Description
Is vdiffr still recommended over testthat::expect_snapshot() for testing plots (e.g., ggplot2 objects)?
I assume yes (per #617 (comment), #1265 (comment)) but wanted to confirm, since testthat has seen a lot of great enhancements in the snapshot realm :)
Motivating example (modified from #1393): I was hoping (perhaps naively) to use:
test_that("ggplot", {
library(ggplot2)
expect_snapshot(ggplot(data.frame(), aes(1,2)) + geom_point())
})
But, this errors:
ββ Error ('test-ggplot.R:4:3'): ggplot βββββββββββββββββββββββββββββββββββββββββ
Error in `UseMethod("snapshot_replay", x)`: no applicable method for 'snapshot_replay' applied to an object of class "recordedplot"
Backtrace:
β
1. ββtestthat::expect_snapshot(ggplot(data.frame(), aes(1, 2)) + geom_point()) at test-ggplot.R:4:3
2. ββtestthat:::with_is_snapshotting(...)
3. ββtestthat:::verify_exec(quo_get_expr(x), quo_get_env(x), replay)
4. ββbase::unlist(lapply(results, replay))
5. ββbase::lapply(results, replay)
6. ββtestthat (local) FUN(X[[i]], ...)
7. ββtestthat:::snapshot_replay(x, state, transform = transform, cnd_class = cnd_class)
Metadata
Metadata
Assignees
Labels
No labels