You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This is a working demo of (and template for) a single shiny app fullywrapped into an R package that is complete with unit testing, codecoverage, and end-to-end shiny app testing with shinytest2.
Single-App R Package Benefits
All latest functions, ui/server code, and dependencies for a singleapp are accessible after installing or updating a single R package
All functionality of the app, including simulated user-interactions,as well as load-testing, can be included in the unit and coveragetests executed by a standard R package check
Workflow for automated CI/Deployment of app is simplified to that ofa standard R package. App can be deployed as a docker image as partof workflow that checks, tests, and builds the package
Additional Resources
To unit tests this shiny app, including simulated user actions andsnapshots, I utilize the package shinytest2 in conjuction withsnapshot expectations from package testthat
For additional information on how to load test shiny apps, bothlocally as well as a deployed app, see shinyloadtest for more info
For an example of a multi-app R package, seehere(LINK).
Package Structure
R/├──app-run.R........................App server/ui code + function to launch app ├──app-plots.R......................App functionality to build and save plot/data └──app-utils.R......................All other functions needed during app sessiontests/testthat/├── test-app-run.R..................End-to-end app and user-interactions tests ├── test-app-plots.R................Isolated unit testing of app plot functions├── test-app-utils.R................Isolated unit testing of other app functions├── _snaps..........................Snapshots are saved here in testing└── _tools..........................Contains helpers for debugging ├── dl-artifacts.sh.............Download gh actions artifacts by id └── list-artifacts.sh...........List all gh actions artifacts for repoinst/ ├── docker..........................Docker context used in CI/Deploy Workflow│ ├── Dockerfile..................Dockerfile to build image of deployed app │ └── Rprofile.site...............Copied to image on docker build└── docs └── template.Rmd................Template Report used by app on user action.github/workflows/├── R-CMD-check.yaml................Test app via package build/check steps└── test-coverage.yaml..............Test and report coverage of app codebase
Install & Run App
In R Session
This package exports a single R function that launches the packagedshiny app: