Skip to contents

This vignette walks through setting up shinytest2 for a shiny app-package.

Set up

shinytest2 requires a few steps to get up and running, so I’ve included my start up steps below (in hopes that someone might find them useful).

Chromium

First make sure you have Chromium headless browser installed. Chromium is the browser used to test and debug shiny apps with shinytest2.

If you’re using macOS, you can install Chromium using homebrew:

brew install --cask chromium
==> Downloading https://download-chromium.appspot.com/dl/Mac?type=snapshots
==> Downloading from https://commondatastorage.googleapis.com/chromium-browser-s
######################################################################### 100.0%
Warning: No checksum defined for cask 'chromium', skipping verification.
==> Installing Cask chromium
==> Moving App 'Chromium.app' to '/Applications/Chromium.app'
==> Linking Binary 'chromium.wrapper.sh' to '/usr/local/bin/chromium'
🍺  chromium was successfully installed!

chromote

The chromote package allows R to open Chromium. I had to make sure R knew where to find the Chromium application (this section helps) by passing the path to the app to Sys.setenv() (you can locate the path to Chromium using by holding command (⌘) and clicking on the application icon)

remotes::install_github("rstudio/chromote", force = TRUE, quiet = TRUE)
library(chromote)

Find your Chromium app:

chromote::find_chrome()
#>            google-chrome 
#> "/usr/bin/google-chrome"

This didn’t work for me (kept locating Chrome.app), so I had to find it with the Terminal:

Sys.setenv(CHROMOTE_CHROME = "/Applications/Chromium.app/Contents/MacOS")

I also verified the Chromium app opened with ChromoteSession$new()

b <- ChromoteSession$new()
b$view()