Skip to contents

Creates a shinytest2::AppDriver for app, which screenshots only what the app's crow_screenshot_args attribute selects (see get_screenshot_args_attr()), such as the module UI of module2app(). The driver stops when .local_envir exits.

Usage

local_app_driver(
  app,
  screenshot_args = app_screenshot_args(app),
  ...,
  .local_envir = parent.frame()
)

Arguments

app

A function without arguments that returns a shiny app, such as counter_button_app or one from shinytest2_app_fn(). Other values passed to app_dir of shinytest2::AppDriver$new() also work.

screenshot_args

Passed to shinytest2::AppDriver$new().

...

Passed to shinytest2::AppDriver$new().

.local_envir

The environment whose exit stops the driver.

Details

To make shinytest2 run the working tree of your package, instead of an outdated installed version, pass a function as app (see shinytest2_app_fn()).

Examples

if (FALSE) { # \dontrun{
test_that("counter counts", {
  driver <- local_app_driver(counter_button_app)
  driver$click(selector = "#test_object-button")
  expect_equal(driver$get_value(export = "res"), 1L)
})
} # }