Nov 30, 2026
|
59 min
|
659 views
How do you test a Shiny App in R? testthat and shinytest2 explained | Barret Schloerke | DS Lab
You test a Shiny app in R by writing testthat unit and snapshot tests for your code, then using shinytest2 to record browser tests that check your app’s values and screenshots, so you catch regressions without clicking through the app by hand.
In this Data Science Lab session, Barret Schloerke from the Shiny team at Posit shows how to test Shiny apps in R, starting with the testthat basics and ending with shinytest2 and reactlog. Hosts Libby and Isabella Velásquez run it as part of “Testober”, with audience questions throughout.
The Data Science Lab is a live weekly call. Register at pos.it/dslab! Discord invites go out each week on lives calls. We’d love to have you! It’s is an open, messy space for learning and asking questions. Think of it like pair coding with a friend or two. Learn something new, and share what you know to help others grow.
This episode was originally recorded on October 20, 2026.
0:00 Welcome, Discord, and housekeeping 1:00 Meet Barret Schloerke and the Shiny team 5:33 testthat basics 6:00 expect_equal() 7:44 waldo and clearer test failures 10:06 Snapshot testing 17:28 Snapshot files (CSV, JSON, PNG) 22:29 Skipping tests and committing snapshots to git 24:38 The Old Faithful example app 27:21 Why unit test your app instead of testing by hand 29:05 shinytest2: record_test() and your first test 31:37 Rerunning tests with test_app() 33:49 Reviewing screenshot differences 34:48 Headless browsers and how shinytest2 runs your app 39:14 chromote questions, including temp files 44:04 shinytest2 for packages, Rhino, and Golem 46:06 Testing non-UI functions (data wrangling and ETL) 47:42 reactlog: what it shows about your app 52:29 A larger reactlog example (CRAN Whales) 55:07 profvis for time and memory 56:19 What’s coming in reactlog 58:16 Wrap-up and next week’s Shiny for Python session
Resources mentioned:
Shiny: https://shiny.posit.co/ Positron (IDE that Barret uses): https://positron.posit.co/ Shinytest2: https://rstudio.github.io/shinytest2/ Old Faithful example: https://shiny.posit.co/r/gallery/start-simple/faithful/ shinytest2: https://rstudio.github.io/shinytest2/ expect_equal: https://testthat.r-lib.org/reference/equality-expectations.html Mastering Shiny: https://mastering-shiny.org/scaling-testing.html testthat: https://testthat.r-lib.org/reference/equality-expectations.html waldo: https://waldo.r-lib.org/ Snapshot testing in testthat: https://testthat.r-lib.org/reference/expect_snapshot.html Third edition page: https://testthat.r-lib.org/articles/third-edition.html Using shinytest2 with R packages: https://rstudio.github.io/shinytest2/articles/use-package.html Rhino by Appsilon: https://appsilon.github.io/rhino/ Golem docs: https://thinkr-open.github.io/golem/ reactlog: https://rstudio.github.io/reactlog/ reactlog video from 2022: https://www.youtube.com/watch?v=slXcW99ftk4 profvis: https://profvis.r-lib.org/ lobstr: https://lobstr.r-lib.org/ chromote: https://rstudio.github.io/chromote/
Barret Schloerke, Isabella Velásquez, Shiny Team
chromote
lobstr
Positron
profvis
reactlog
rstudio
Shiny for Python
Shiny
shinytest2
testthat
waldo