Skip to content

Breaking changes to Appdriver tests with new version 0.2.1 #330

@matt-sd-watson

Description

@matt-sd-watson

With the release of 0.2.1, my R package test (which contains a Shiny app) is breaking. Below is the code for the test:

require(cytosel)

test_that("{shinytest2} recording: cytosel", {
  testthat::local_edition(3)

  # set the app depending on the interactive execution to avoid a no package found error
  if (interactive()) {
    cytosel_app <- test_path("../../")
  } else {
    cytosel_app <- cytosel::cytosel()
  }
  
  announce_snapshot_file("cytosel-001.png")
  announce_snapshot_file("cytosel-002.png")
  app <- AppDriver$new(cytosel_app,
                       variant = platform_variant(), name = "cytosel", height = 732,
      width = 1161, load_timeout = 1e+05
      # shinyOptions = list(test.mode = TRUE)
      )
    
    # Sys.sleep(7)
    app$wait_for_value(output = "cytosel_logo")
    # IMPORTANT: only run the tests non-interactively using Github actions
    # currently devtools test and devtools check give different screenshot results
    skip_if(interactive())
    app$expect_screenshot()

    skip_if(interactive())
    app$click("help_guide")
    Sys.sleep(7)
    app$expect_screenshot()

})

Where `cytosel' is the name of the package and the function that calls the Shiny app.

Previously, this test passed with v0.2.0 in Github Actions, but now the following error occurs:

══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test-shinytest2.R:16'): {shinytest2} recording: cytosel ─────────────
Error in `app_initialize(self, private, app_dir = app_dir, ..., load_timeout = load_timeout, 
    timeout = timeout, wait = wait, expect_values_screenshot_args = expect_values_screenshot_args, 
    screenshot_args = screenshot_args, check_names = check_names, 
    name = name, variant = variant, view = view, height = height, 
    width = width, seed = seed, clean_logs = clean_logs, shiny_args = shiny_args, 
    render_args = render_args, options = options)`: Identified global objects via static code inspection (new("standardGeneric", .Data = function (x, decreasing = FALSE,; ...); standardGeneric("sort"), generic = structure("sort", package = "BiocGenerics"),; package = "BiocGenerics", group = list(), valueClass = character(0),; signature = "x", default = new("derivedDefaultMethod", .Data = function (x,; decreasing = FALSE, ...); ...; package = "methods"), defined = new("signature", .Data = "ANY",; names = "x", package = "methods"), generic = structure("sort", package = "base")))(x,; decreasing, ...))). Failed to locate global object in the relevant environments: 'x'


ℹ You can inspect the failed AppDriver object via `rlang::last_error()$app`
ℹ AppDriver logs:
{shinytest2} R info 21:13:19.25 Start AppDriver initialization
{shinytest2} R info 21:13:19.95 Error while initializing AppDriver:
                                Identified global objects via static code inspection (new("standardGeneric", .Data = function (x, decreasing = FALSE,; ...); standardGeneric("sort"), generic = structure("sort", package = "BiocGenerics"),; package = "BiocGenerics", group = list(), valueClass = character(0),; signature = "x", default = new("derivedDefaultMethod", .Data = function (x,; decreasing = FALSE, ...); ...; package = "methods"), defined = new("signature", .Data = "ANY",; names = "x", package = "methods"), generic = structure("sort", package = "base")))(x,; decreasing, ...))). Failed to locate global object in the relevant environments: 'x'


Caused by error in `globalsByName()`:
! Identified global objects via static code inspection (new("standardGeneric", .Data = function (x, decreasing = FALSE,; ...); standardGeneric("sort"), generic = structure("sort", package = "BiocGenerics"),; package = "BiocGenerics", group = list(), valueClass = character(0),; signature = "x", default = new("derivedDefaultMethod", .Data = function (x,; decreasing = FALSE, ...); ...; package = "methods"), defined = new("signature", .Data = "ANY",; names = "x", package = "methods"), generic = structure("sort", package = "base")))(x,; decreasing, ...))). Failed to locate global object in the relevant environments: 'x'
Backtrace:
     ▆
  1. ├─AppDriver$new(...) at test-shinytest2.R:16:2
  2. │ └─shinytest2 (local) initialize(...)
  3. │   └─shinytest2:::app_initialize(...)
  4. │     ├─base::withCallingHandlers(...)
  5. │     └─shinytest2:::app_initialize_(self, private, ..., view = view)
  6. │       └─shinytest2:::app_save(app_dir)
  7. │         └─shinytest2:::app_data(app)
  8. │           └─shinytest2:::app_server_globals(server)
  9. │             └─globals::globalsOf(server, envir = environment(server), recursive = TRUE)
 10. │               └─globals::globalsOf(...)
 11. │                 └─base::tryCatch(...)
 12. │                   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 13. │                     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 14. │                       └─value[[3L]](cond)
 15. │                         └─base::stop(ex)
 16. └─shinytest2 (local) `<fn>`(`<smplErrr>`)
 17.   └─shinytest2:::app_abort(...)
 18.     └─rlang::abort(..., app = self, call = call)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions