shinytest2

The shinytest2 package provides tools for creating and running automated tests on Shiny applications.
Published

September 15, 2026

The shinytest2 package is one part of a comprehensive strategy for testing Shiny applications. To understand how it fits in, please see the testing overview.

shinytest2 drives your application in a headless Chrome browser, simulating user actions such as clicking buttons and setting inputs, and records snapshots of the application state for comparison in future test runs. Tests are written with testthat, so they run alongside the rest of your tests.

To get started, call shinytest2::record_test() in your app directory, interact with your app, and save the recording. The recorded test is written to tests/testthat/test-shinytest2.R:

library(shinytest2)

test_that("{shinytest2} recording: myapp", {
  app <- AppDriver$new(name = "myapp", height = 407, width = 348)
  app$set_inputs(size = 6)
  app$expect_values()
})

Run it with shinytest2::test_app() or shiny::runTests().

Learn more

Coming from the older, superseded shinytest package? shinytest2::migrate_from_shinytest() converts your existing tests.