Skip to content

Commit f60963c

Browse files
authored
Address issues related to testing with shinytest2 the examples (#915)
# Pull Request Attempts to fix insightsengineering/coredev-tasks#536 on this package. 1. system.file don't raise an error (but I need to check if it is empty or it reports useful info). 2. When there is an error on a shiny session the test of the example fails. 3. Stop using `load_all` inside test-examples. 4. Checks all examples due to upstream issues being fixed since last year. For testing 2 create a new file and add a new file and document to add this example: ``` #' Example failing #' @export #' @examples #' app <- init( #' data = teal_data( #' new_iris = transform(iris, id = seq_len(nrow(iris))), #' new_mtcars = transform(mtcars, id = seq_len(nrow(mtcars))) #' ), #' modules = modules( #' module( #' "Iris Sepal.Length histogram", #' server = function(input, output, session, data) { #' stop("yada") # 🔍 this will fail the app #' }, #' ui = function(id, ...) { #' ns <- NS(id) #' plotOutput(ns("hist")) #' }, #' datanames = "new_iris" #' ) #' ) #' ) #' if (interactive()) { #' shinyApp(app$ui, app$server) #' } module_error <- function() {} ``` Then for all check with `R CMD check` or `devtools::test(filter = "examples")` from plain R session.
1 parent 56e2abc commit f60963c

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

tests/testthat/test-examples.R

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ with_mocked_app_bindings <- function(code) {
3636
# workaround of https://github.com/rstudio/shinytest2/issues/381
3737
# change to `print(shiny__shinyApp(...))` and remove allow warning once fixed
3838
mocked_shinyApp <- function(ui, server, ...) { # nolint object_linter.
39-
functionBody(server) <- bquote({
40-
.hint_to_load_package <- add_facet_labels # Hint to shinytest2 when looking for packages in globals
41-
.(functionBody(server))
42-
})
4339
mocked_runApp(do.call(shiny__shinyApp, append(x = list(ui = ui, server = server), list(...))))
4440
}
4541

@@ -135,13 +131,6 @@ with_mocked_app_bindings <- function(code) {
135131
)
136132
}
137133

138-
strict_exceptions <- c(
139-
# https://github.com/r-lib/gtable/pull/94
140-
"tm_outliers.Rd",
141-
"tm_g_response.Rd",
142-
"tm_a_pca.Rd"
143-
)
144-
145134
discard_validation_regex <- list(
146135
"tm_file_viewer.Rd" = "Please select a file\\.",
147136
"tm_g_distribution.Rd" = "Please select a test"
@@ -155,11 +144,6 @@ for (i in rd_files()) {
155144
testthat::skip("chromium")
156145
skip_if_too_deep(5)
157146
testthat::skip_if_not_installed("pkgload")
158-
if (basename(i) %in% strict_exceptions) {
159-
op <- options()
160-
withr::local_options(opts_partial_match_old)
161-
withr::defer(options(op))
162-
}
163147
# Allow for specific validation errors for individual examples
164148
withr::local_options(
165149
list(

0 commit comments

Comments
 (0)