From 4ad706b6dac86c0459bbcbf8f08e5a672123433f Mon Sep 17 00:00:00 2001 From: cicdguy <26552821+cicdguy@users.noreply.github.com> Date: Tue, 9 Apr 2024 10:10:01 -0500 Subject: [PATCH] Fix the unit test and move to shinytest2 (#224) Migrate to `shinytest2` --- DESCRIPTION | 6 +++--- tests/testthat/test-shiny.R | 28 +++++++++++++--------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e20d364a..8e014af2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,8 +19,8 @@ Suggests: future, httr, knitr, - shinytest, - testthat (>= 2.0) + shinytest2, + testthat (>= 3.0) VignetteBuilder: knitr biocViews: @@ -28,4 +28,4 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 diff --git a/tests/testthat/test-shiny.R b/tests/testthat/test-shiny.R index 6fed2d67..4d8692cd 100644 --- a/tests/testthat/test-shiny.R +++ b/tests/testthat/test-shiny.R @@ -1,25 +1,23 @@ test_that("The Shiny App returns a proper greeting", { - library(shinytest) - app <- ShinyDriver$new( + library(shinytest2) + app <- AppDriver$new( "shiny-app/", - loadTimeout = 1e5, - debug = "all", - phantomTimeout = 1e5, + load_timeout = 1e5, + timeout = 1e5, seed = 123 ) - app$getDebugLog() + app$get_logs() # Set input - app$setInputs(name = "john") - app$setInputs(greet = "click") - output <- app$getValue(name = "greeting") + app$set_inputs(name = "john") + app$click("greet") - # test + # Get output + output <- app$get_value(output = "greeting") + + # Assert expect_equal(output, "Hello, John") - # wait for the process to close gracefully - # this allows covr to write out the coverage results - p <- app$.__enclos_env__$private$shinyProcess - p$interrupt() - p$wait() + # Stop the app + app$stop() })