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

Use {globals} hint to load tmc on test-examples #1119

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions tests/testthat/test-examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ with_mocked_app_bindings <- function(code) {
# change to `print(shiny__shinyApp(...))` and remove allow warning once fixed
mocked_shinyApp <- function(ui, server, ...) { # nolint object_name_linter.
functionBody(server) <- bquote({
pkgload::load_all(
.(normalizePath(file.path(testthat::test_path(), "..", ".."))),
export_all = FALSE,
attach_testthat = FALSE,
warn_conflicts = FALSE
)
.hint_to_load_package <- tm_g_ci # Hint to shinytest2 when looking for packages in globals
.(functionBody(server))
})
print(do.call(shiny__shinyApp, append(x = list(ui = ui, server = server), list(...))))
Expand Down Expand Up @@ -114,14 +109,16 @@ strict_exceptions <- c(
"tm_g_ci.Rd",
"tm_g_ipp.Rd",
"tm_g_pp_adverse_events.Rd",
"tm_g_pp_vitals.Rd"
"tm_g_pp_vitals.Rd",
"tm_t_shift_by_arm.Rd",
"tm_t_summary_by.Rd"
)

for (i in rd_files()) {
testthat::test_that(
paste0("example-", basename(i)),
{
testthat::skip_on_cran()
# testthat::skip_on_cran()
if (basename(i) %in% strict_exceptions) {
op <- options()
withr::local_options(opts_partial_match_old)
Expand Down
Loading