Repository navigation
shinytest2 0.5.0
Lifecycle changes
-
load_app_env()has been superseded byload_app_support(). This new
function aligns its name withlocal_app_support()and
with_app_support(), and similarly, it requires anapp_dirparameter
(#328). -
test_app(check_setup=)is now deprecated. Checking is no longer required
as default behavior, asload_app_env()has been superseded by
with_app_support()andlocal_app_support(), which provide a more robust
and flexible way to scope app support files such asglobal.R,app.R,
server.R, andui.R(#328).
New features
-
AppDriver$new(app_dir=)now supports local package development for the
background Shiny app process. In the background test R process, any
library(<pkg>)orrequire(<pkg>)call automatically executes
pkgload::load_all()to load the local R package's source code. Installing
the package before testing is no longer required (#402). -
AppDriver$new(app_dir=)now supports function execution. You must run the
app (or document) yourself or return a Shiny app object. Similar to{mirai},
all packages must be loaded withlibrary()orrequire()again as the
function runs in the background R process (#402). -
Added
local_app_support(),with_app_support(), andload_app_support().
local_app_support()andwith_app_support()provide package authors a
flexible way to scope app support files such asglobal.R,app.R,
server.R, andui.Rwithin tests. Non-package authors should still use
load_app_support()within theirsetup-shinytest2.Rfile. See
?local_app_supportfor more details (#328). -
record_test()gained arecord_in_packageparameter. IfTRUE(default)
and the current working directory is within a package, the test file is saved
to the package'stests/testthat/directory. IfFALSE, the test file is
saved to the app'stests/testthat/directory (#328). -
Package authors should now test Shiny applications within their own
{testthat}tests instead of usingtest_app(). This collects snapshots in a
single location using the package's existing{testthat}infrastructure. Use
with_app_support()orlocal_app_support()to load app support files as
needed. See the use-package
vignette for
more details (#328).
Bug fixes and minor improvements
-
AppDriver$expect_values()now works correctly with{testthat}v3.3.0,
which changed expectation behavior for screenshot snapshots (#418). -
record_test()now only saves the setup file for local app testing and not
within package app testing. When recording a test for an app inside a package,
local_app_support()is added to the top of the testing code. If the current
working directory is within a package andrecord_in_package = TRUE
(default), the test file is saved to the package'stests/testthat/
directory. Ifrecord_in_package = FALSE, the test file is saved relative to
the app'stests/testthat/directory (#328). -
Migrated from
{httr}to{httr2}for all HTTP requests made by
{shinytest2}(#420, #428).