The goal of msst2ap
is to demonstrate how to test a shiny app-package using testthat
and shinytest2
All examples come from the Modules chapter of Mastering Shiny.
Installation
You can install msst2ap
from GitHub using the code below:
remotes::install_github("mjfrigaard/msst2ap",
force = TRUE, quiet = TRUE
)
Set up
There are specific instructions for setting up shinytest2
in the shinytest2-setup.Rmd
vignette.
Utility function/testServer()
tests
Tests for the utility functions are in unit-tests.Rmd
vignette. Test for the module server functions and standalone app functions are in the testserver-tests.Rmd
vignette.
shinytest2
tests
The output from devtools::test()
is below:
==> devtools::test()
ℹ Testing msst2ap
✔ | F W S OK | Context
✔ | 1 | shinytest2-datasetApp [4.8s]
⠼ | 5 | shinytest2-gghistApp
⠋ | 11 | shinytest2-gghistApp
⠙ | 12 | shinytest2-gghistApp
✔ | 13 | shinytest2-gghistApp [5.1s]
✔ | 5 | shinytest2-histogramApp [3.6s]
✔ | 2 | shinytest2-selectVarApp [2.2s]
✔ | 1 | shinytest2 [4.2s]
══ Results ══════════════════════════════════════════════════════════════════
Duration: 19.9 s
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 22 ]
🔥 Your tests are lit 🔥
Known issue
The following warning is given when running shinytest2
tests in an app package:
Warning message:
In shiny::loadSupport(app_dir, renv = renv, globalrenv = globalrenv) :
Loading R/ subdirectory for Shiny application, but this directory appears to
contain an R package. Sourcing files in R/ may cause unexpected behavior.
Don’t worry–there is an open issue on GitHub for this!