testServer: how to set inputs in embedded modules?

I could not get the syntax correct to inputs of an embedded module:

library(shiny)
myModuleServer <- function(id, multiplier = 2, prefix = "I am ") {
  moduleServer(id, function(input, output, session) {
    myreactive <- reactive({
      input$x * multiplier
    })
    output$txt <- renderText({
      paste0(prefix, myreactive())
    })
  })
}

server <- function(input, output, session) {
  x <- reactive(input$a * input$b)
  ms = myModuleServer("ms")
}

testServer(server, {
  session$setInputs(a = 2, b = 3)
  stopifnot(x() == 6)
  # How to set inputs of embedded module?
  # Something like this, but obviously it does not work
  # session$setInputs(NS("ms")$x = 1)
  # stopifnot(NS("ms")$myreactive() == 2)

})

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.