shiny icon indicating copy to clipboard operation
shiny copied to clipboard

Cannot determine if app has been started in test mode

Open bersbersbers opened this issue 3 years ago • 0 comments

System details

Output of sessionInfo():

R version 4.1.2 (2021-11-01)
Platform: x86_64-suse-linux-gnu (64-bit)
Running under: openSUSE Leap 15.2

Matrix products: default
BLAS:   /usr/lib64/R/lib/libRblas.so
LAPACK: /usr/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_1.7.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8       digest_0.6.29    later_1.3.0      mime_0.12        R6_2.5.1         jsonlite_1.7.3   lifecycle_1.0.1  xtable_1.8-4     magrittr_2.0.2   cachem_1.0.6    
[11] rlang_1.0.1      cli_3.1.1        promises_1.2.0.1 jquerylib_0.1.4  bslib_0.3.1      ellipsis_0.3.2   tools_4.1.2      import_1.2.0     glue_1.6.1       httpuv_1.6.5    
[21] fastmap_1.1.0    compiler_4.1.2   htmltools_0.5.2  sass_0.4.0      

Example application or steps to reproduce the problem

library(shiny)
ui <- fluidPage(
  # These two are always TRUE
  is.null(getShinyOption("testmode")),
  is.null(getOption("shiny.testmode")),
)
server <- function(input, output) NULL

# Run the app in test mode
# Each of the following two modes works, reporting
# "Running application in test mode."
mode <- 1

if (mode == 1) {
  options(shiny.testmode = TRUE)
  stopifnot(getOption("shiny.testmode"))
  shiny::runApp(shinyApp(ui = ui, server = server))
}

if (mode == 2) {
  shiny::runApp(shinyApp(ui = ui, server = server), test.mode = TRUE)
}

Describe the problem in detail

The app shows "TRUE TRUE", indicating that the testmode options as seen by the app are both NULL.

In both modes, I would expect at least getShinyOption("testmode") to return TRUE. In mode 1, I would also expect getOption("shiny.testmode") to return TRUE.

bersbersbers avatar Feb 14 '22 09:02 bersbersbers