tests/testthat/test-app-hello-variant.R

# shinytest2 code using `app$**()`:
test_that("screenshots need a variant", {
  skip_if_no_apps()

  app <- AppDriver$new(test_path("apps/hello"))

  app$set_inputs(name = "Hadley")
  app$set_inputs(greet = "click")

  # Can save values. Variant acts like `NULL`
  app$expect_values()

  expect_error(
    app$expect_screenshot(),
    "can not call `$expect_screenshot()`",
    fixed = TRUE
  )
})

# Tests where the variant is supplied (both `NULL` and `platform_variant()`) are done in many other files.

Try the shinytest2 package in your browser

Any scripts or data that you put into this service are public.

shinytest2 documentation built on Jan. 10, 2026, 1:07 a.m.