R/test_module.R

Defines functions test_module

#' Helper function for testing modules
#'
#' @param mod_name Module function name prefix (without `_ui` or `_server`)
#' @param args_ui named list of arguments/values to pass to the UI function
#' @param args_server named list of arguments/values to pass to the server function
#'
#' @noRd
test_module <- function(ui_fun, server_fun, args_ui = list(), args_server = list()) {

  id <- "mod_id"

  shinyApp(
    fluidPage(
      do.call(ui_fun, c(id = id, args_ui))
    ),
    function(input,output,session){
      vals <- do.call(server_fun, c(id = id, args_server))

      exportTestValues(vals = {vals()})
    }
  )
}

Try the tfrmtbuilder package in your browser

Any scripts or data that you put into this service are public.

tfrmtbuilder documentation built on Oct. 12, 2024, 1:07 a.m.