Skip to contents

Wrapper around shinytest2::AppDriver(). Shows only the shiny app at launch. To show interactions with an app, use a different function.

Usage

get_screenshot_from_app(
  appDir,
  screenshot_args = get_screenshot_args_attr(appDir),
  name = character(1L),
  file = NULL,
  strict = FALSE
)

Arguments

appDir

The application to run. Should be one of the following:

  • A directory containing server.R, plus, either ui.R or a www directory that contains the file index.html.

  • A directory containing app.R.

  • An .R file containing a Shiny application, ending with an expression that produces a Shiny app object.

  • A list with ui and server components.

  • A Shiny app object created by shinyApp().

screenshot_args

Passed to shinytest2::AppDriver's $new() method.

name

If the shiny app is developed inside a package (recommended), the name of that package. The screenshot is created using the (last) installed (not pkgload::load_all()d) version of that package. When the name is provided, the function can test whether it is using the installed version of that package, to avoid confusion (recommended).

file

Path to save the screenshot to; only used for testing. Leave to NULL.

strict

Should the function error out, when the various conditions for creating screenshots are not met? To reduce friction during development, the function will default to just issuing a warning. Instead of the screenshot, it then returns the reason for the failure as a string.

Examples

if (FALSE) { # \dontrun{
get_screenshot_from_app(examples_app())
} # }