print_yaml <- function(filename) {
  cat("```yaml", readLines(filename), "```", sep = "\n")
}

test-app

RStudio community

This action tests a Shiny application (or Shiny-based document) using the {shinytest2} package. The ${{ inputs.app-dir}}/tests/testthat/_snaps directory will be uploaded if enabled (default).

Usage

Inputs available:

Typical (single app testing) GHA step usage:

- uses: rstudio/shinytest2/actions/test-app@actions/v1
  with:
    app-dir: |
      dir/to/app

Multiple Apps can be tested by supplying multiple directories to app-dir separated by a newline:

- uses: rstudio/shinytest2/actions/test-app@actions/v1
  with:
    app-dir: |
      dir/to/app1
      dir/to/app2

Example workflows

These workflows are a good building block / starting point for testing your Shiny applications. You may need to alter what is actually executed to fit your needs.

Dependencies in DESCRIPTION file

Install workflow using:

usethis::use_github_action(
  url = "https://github.com/rstudio/shinytest2/raw/main/actions/test-app/example-test-app-descrption.yaml",
  save_as = "test-app-description.yaml"
)

Workflow contents:

print_yaml("example-test-app-description.yaml")

Dependencies managed by {renv}

Install workflow using:

usethis::use_github_action(
  url = "https://github.com/rstudio/shinytest2/raw/main/actions/test-app/example-test-app-renv.yaml",
  save_as = "test-app-renv.yaml"
)

Workflow contents:

print_yaml("example-test-app-renv.yaml")

App within Package structure

If you are using a local package and want to test an application within the same repo, this may be a good option. However, it is recommended to try to execute these tests as a part of your standard {testthat} testting.

Install workflow using:

usethis::use_github_action(
  url = "https://github.com/rstudio/shinytest2/raw/main/actions/test-app/example-test-app-package.yaml",
  save_as = "test-app-package.yaml"
)

Workflow contents:

print_yaml("example-test-app-package.yaml")

Development

The test-app action uses a sliding git tag that follows the pattern actions/vX, e.g. actions/v1. For historical reasons, we also support the v1 tag, but future versions will only be available under the actions/vX tag.

The test-app action release cycle is not dependent on the shinytest2 package cycle. When changes are made to the test-app action, you should force-update the current sliding tag version:

git tag -f v1            # update historical v1 tag
git tag -f actions/v1    # update sliding tag
git push --tags --force  # push tag to github

License

The scripts and documentation in this project are released under the MIT License

Contributions

Contributions are welcome!



rstudio/shinytest2 documentation built on March 29, 2025, 10:58 p.m.