1# By default, if vdiffr is not installed, all visual tests are skipped unless
2# VDIFFR_RUN_TESTS is explicitly set to "true", which should be the case only on
3# a GitHub Actions CI runner with stable version of R.
4
5if (requireNamespace("vdiffr", quietly = TRUE) && utils::packageVersion('testthat') >= '3.0.3') {
6  expect_doppelganger <- vdiffr::expect_doppelganger
7} else {
8  # If vdiffr is not available and visual tests are explicitly required, raise error.
9  if (identical(Sys.getenv("VDIFFR_RUN_TESTS"), "true")) {
10    abort("vdiffr is not installed")
11  }
12
13  # Otherwise, assign a dummy function
14  expect_doppelganger <- function(...) skip("vdiffr is not installed.")
15}
16