Skip to content

shinytest2 0.5.0

Choose a tag to compare

@schloerke schloerke released this 09 Jan 21:42

Lifecycle changes

  • load_app_env() has been superseded by load_app_support(). This new
    function aligns its name with local_app_support() and
    with_app_support(), and similarly, it requires an app_dir parameter
    (#328).

  • test_app(check_setup=) is now deprecated. Checking is no longer required
    as default behavior, as load_app_env() has been superseded by
    with_app_support() and local_app_support(), which provide a more robust
    and flexible way to scope app support files such as global.R, app.R,
    server.R, and ui.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>) or require(<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 with library() or require() again as the
    function runs in the background R process (#402).

  • Added local_app_support(), with_app_support(), and load_app_support().
    local_app_support() and with_app_support() provide package authors a
    flexible way to scope app support files such as global.R, app.R,
    server.R, and ui.R within tests. Non-package authors should still use
    load_app_support() within their setup-shinytest2.R file. See
    ?local_app_support for more details (#328).

  • record_test() gained a record_in_package parameter. If TRUE (default)
    and the current working directory is within a package, the test file is saved
    to the package's tests/testthat/ directory. If FALSE, the test file is
    saved to the app's tests/testthat/ directory (#328).

  • Package authors should now test Shiny applications within their own
    {testthat} tests instead of using test_app(). This collects snapshots in a
    single location using the package's existing {testthat} infrastructure. Use
    with_app_support() or local_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 and record_in_package = TRUE
    (default), the test file is saved to the package's tests/testthat/
    directory. If record_in_package = FALSE, the test file is saved relative to
    the app's tests/testthat/ directory (#328).

  • Migrated from {httr} to {httr2} for all HTTP requests made by
    {shinytest2} (#420, #428).