Testing of shiny modules with other modules

In a large Shiny App, I have a lot of modules with other modules within. These nested modules also sometimes have input, like e.g. buttons. The following example is a MWE for this problem. How can I test summaryServer and simulate a click or other Input within rangeServer?

summaryUI <- function(id) {
    textOutput(NS(id, "min")),
    textOutput(NS(id, "mean")),
    textOutput(NS(id, "max")),
    rangeUI(NS(id, "range"))
summaryServer <- function(id, var) {
  moduleServer(id, function(input, output, session) {
    d_act = reactiveVal("Haha nope")
    range_val = rangeServer("range", var = var)
    # waits to range_val
      output$min <- renderText(range_val()[[1]])
      output$max <- renderText(range_val()[[2]])
      output$mean <- renderText(mean(var()))

rangeUI = function(id) {
  textInput(inputId = NS(id, "go"),label = "Go")
rangeServer = function(id, var){
  moduleServer(id, function(input, output, session){
   # when button gets clicked
      range(var(), na.rm = TRUE)
    },ignoreInit = TRUE, ignoreNULL = TRUE)


ui <- fluidPage(

server <- function(input, output, session) {
  x = reactiveVal(1:10)
  summaryServer("sum", x)

shinyApp(ui, server)

x <- reactiveVal(1:10)
testServer(summaryServer, args = list(var = x), {

  cat("var active?", d_act(),"\n")
  # How to call/set "go" here?

  cat("var active?", d_act(),"\n")

1 Like

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.