feat: Allow for dev packages to be dynamically loaded#402
Merged
Conversation
gadenbuie
reviewed
Feb 10, 2025
…into pkg_test_env
Co-Authored-By: Garrick Aden-Buie <garrick@adenbuie.com>
This was referenced Feb 12, 2025
* main: fix(testthat): Use `muffle_expectation`, not `continue_test` (#418) v0.4.1 (#415) fix: default `transform=` to NULL, not itself (#413) Increment version number to 0.4.0.9000 v0.4.0 (#410) Pre-release cleanups for shinytest 2 0.3.3 (#409) feat: Add `transform=` parameter to `$expect_download()` and `$expect_values()` (#403)
…into pkg_test_env
Collaborator
Author
|
Merging to move forward with a release soon |
schloerke
added a commit
that referenced
this pull request
Nov 18, 2025
* main: fix(snapshot): Use local testthat edition to announcing files (#419) feat: Allow for dev packages to be dynamically loaded (#402) fix(testthat): Use `muffle_expectation`, not `continue_test` (#418) v0.4.1 (#415) fix: default `transform=` to NULL, not itself (#413) Increment version number to 0.4.0.9000 v0.4.0 (#410) Pre-release cleanups for shinytest 2 0.3.3 (#409) feat: Add `transform=` parameter to `$expect_download()` and `$expect_values()` (#403) chore!: Skip all tests using `AppDriver` during CRAN testing. Deprecate `cran=` parameters (#407) docs: Namespace `ChromoteSession` (#406)
This was referenced Nov 18, 2025
Closed
Closed
schloerke
added a commit
that referenced
this pull request
Nov 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for local package development and function-based app initialization in
AppDriver$new(app_dir=). This allows testing Shiny apps without requiring packageinstallation and provides more flexible ways to initialize test apps.
Key Features
library(<pkg>)orrequire(<pkg>)calls automatically executepkgload::load_all()to load the local package's source code instead of requiring the package to be
installed first.
Package installation is no longer required
app_dir=now accepts a function thatreturns a Shiny app object or runs an app directly, providing more flexibility in test
setup.
Examples
Testing a Shiny app in a package without installing
Using a function to initialize your app
Example 1: Function returning a Shiny app object
Example 2: Function for golem/rhino apps
Example 4: Running app directly in function
Technical Details:
testthat::is_checking()) to ensure only installed packagesare used during
R CMD checkupgrades it to load the package first
library()andrequire()in the background R process to intercept packageloading
autoloading to prevent conflicts
Benefits
The magic bits of this PR can be found at https://github.com/rstudio/shinytest2/pull/402/files#diff-1e9839b0ee9b578e1094ebabe21a38467f417789f5b3e17fec51556b6706a851R90 where we use
{pkgload}to load a local R package before callinglibrary()orrequire(). This is done to mimic Shiny app behavior, not testthat testing behavior. I want the author to be required to calllibrary()orrequire()for the app code to be the same both within shinytest2 testing and when run normally.TODO: