The {mockery} package prvoides a way to stub out functions for testing.
Suppose I have an app that I want to test with {shinytest2}, and one of the function calls inside the app's server takes a long time so I'd like to stub it out for a different function.
For example:
library(shiny)
ui <- fluidPage(
numericInput("num", "number for analysis", 5),
textOutput("result")
)
server <- function(input, output, session) {
result <- reactive({
some_heavy_analysis_function(input$num)
})
output$result <- renderText({
result()
})
}
shinyApp(ui, server)
You can imagine some_heavy_analysis_function() is a function defined in my package that takes a long time, but when testing the app with {shinytest2} I will want to replace stub it out for a constant-time function.
The {mockery} package prvoides a way to stub out functions for testing.
Suppose I have an app that I want to test with {shinytest2}, and one of the function calls inside the app's server takes a long time so I'd like to stub it out for a different function.
For example:
You can imagine
some_heavy_analysis_function()
is a function defined in my package that takes a long time, but when testing the app with {shinytest2} I will want to replace stub it out for a constant-time function.