RStudio's Barret Schloerke this week offered Shiny developers details of an R package that promises to improve testing for R Shiny applications. shinytest2 version 0.1.0, on CRAN since Wednesday, allows for automated testing of Shiny web app interactivity. That testing is done via chromote, a headless Chrome browser.
During a presentation at a Shiny conference sponsored by consultants Appsilon, Schloerke showed online attendees the package’s
record_test() function. As the name implies, this function records actions taken inside the testing browser and turns those actions into code. This code can then automatically re-run a user’s initial manual activities and check results. Under the hood, shinytest2 takes some snapshots of the application’s state and uses the testthat unit testing package to store various values over time. When a test is re-run, new values can be compared with earlier ones.