Skip to contents

Function required to perform crash test for a Shiny app. Test whether the app starts and whether it stays alive after a series of random clicks (monkey test) or targeted actions.

Usage

run_crash_test(
  headless_actions = NULL,
  timeout = NULL,
  port = randomPort(max = 3500),
  ...
)

Arguments

headless_actions

Custom code passed as an expression to manipulate the app with headless web browser, for instance app$set_inputs(obs = 200); app$run_js('1+1');. See https://rstudio.github.io/shinytest2/reference/AppDriver.html to get all available methods. If NULL, the app will undergo a classic random Monkey test session, taking a screenshot right after loading and after the monkey test. We do not recommend running a monkey test if your app is pointing to a database, unless the pipeline CI/CD runs in a dedicated test environment.

timeout

Time to wait after starting the subprocess (s). Useful is you know how much time the app takes to load. Defaults to 10 seconds locally and 20 seconds on CI/CD.

port

Port to start the app, default to httpuv::randomPort().

...

Pass extra parameters to run_app_audit. This is useful if you work with packages like golem.

Value

Errors if any of the step fails.

Note

If the Shiny app takes time to load, you may pass load_timeout parameter with duration in ms. For instance load_timeout = 5000, would wait 5 seconds.

Examples

if (FALSE) {
 # Assuming run_app_audit is defined ...
 run_crash_test(
   headless_actions = {
    app$set_inputs(obs = 1000)
    app$get_screenshot("./plop.png")
   }
 )
}