Skip to content

Error "no 'restart' 'continue_test' found" when using shinytest2::AppDriver$expect_values() within test_that() #2288

@liserman

Description

@liserman

The newest release of testthat (3.3.0) leads to issues when trying to record tests for a Shiny-App with shinytest2. When trying to test an internal App for an R-Package, I receive the Error:

Error in invokeRestart("continue_test"): no 'restart' 'continue_test' found

I was able to reproduce the error on multiple machines and with multiple versions of R and shinytest2, yet the issue occurs only with the latest version of testthat (3.3.0) and everything works fine with testthat 3.2.3. I therefore believe this is an issue with testthat 3.3.0 rather than shinytest2. If this is not the case and the updated behaviour is intended, please let me know.

Below, you find a minimal working example, the full Error message including backtrace, and some key session information.

Minimal working example:

library(testthat)
library(shiny)
library(shinytest2)

minimal_app <- function() {
  shinyApp(
    ui = fluidPage(
      actionButton("next_btn", "Next"),
      textOutput("txt")
    ),
    server = function(input, output, session) {
      counter <- reactiveVal(1)
      observeEvent(input$next_btn, {
        counter(counter() + 1)
      }) 
      output$txt <- renderText(counter())
    }
)}

test_that("shinytest2 snapshot triggers invokeRestart error", {
  app <- AppDriver$new(
    app = minimal_app(),
    name = "minimal_snapshot",
    variant = platform_variant()
  )
  
  app$click("next_btn")
  app$wait_for_idle()
  
  app$expect_values()
})

Once I run testthat::test_file(), I receive the following Error:

Error message:

── Error (test_shiny_minimal.R:33:3): shinytest2 snapshot triggers invokeRestart error ──────────────────────────────────────────────────
Error in invokeRestart("continue_test"): no 'restart' 'continue_test' found
Backtrace:

  1. ├─app$expect_values() at test_shiny_minimal.R:33:3
  2. │ └─shinytest2:::app_expect_values(...)
  3. │ ├─base::withCallingHandlers(...)
  4. │ └─shinytest2:::app_expect_screenshot(...)
  5. │ └─shinytest2:::app__expect_snapshot_file(...)
  6. │ ├─base::withCallingHandlers(...)
  7. │ └─testthat::expect_snapshot_file(...)
  8. │ └─testthat::pass()
  9. │ └─testthat::expectation("success", "success")
  10. │ └─testthat::exp_signal(exp)
  11. │ ├─base::withRestarts(...)
  12. │ │ └─base (local) withOneRestart(expr, restarts[[1L]])
  13. │ │ └─base (local) doWithOneRestart(return(expr), restart)
  14. │ └─base::signalCondition(exp)
  15. └─shinytest2 (local) <fn>(<expcttn_>)
  16. └─base::invokeRestart("continue_test")
    [ FAIL 1 | WARN 1 | SKIP 0 | PASS 0 ]

Session info:

R version 4.5.2 (2025-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26200)
attached packages: shiny_1.11.1, shinytest2_0.4.1, testthat_3.3.0

Metadata

Metadata

Assignees

No one assigned

    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