Hi all,
Is there a way to use shinytest2
so that both devtools::check()
and devtools::test()
work with the same code?
As testing with shinytest2
requires loading the app package (otherwise it tests the last installed version of the app, not very practical in terms of workflow), following the answers in this issue, I have added :
if (isTRUE(getOption("shiny.testmode"))) {
pkgload::load_all(rprojroot::is_r_package$find_file())
}
in my inst/app/app.R
.
However, this works for interactive testing but breaks devtools::check()
, which runs fine (because it builds the up-to-date package) without it.
Is there a way to have both working? I tried looking for a way to detect if devtools::check()
is running (to invalidate the if clause above), without success so far.