Skip to content

Commit

Permalink
Fix the unit test and move to shinytest2 (#224)
Browse files Browse the repository at this point in the history
Migrate to `shinytest2`
  • Loading branch information
cicdguy committed Apr 9, 2024
1 parent 301013d commit 4ad706b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ Suggests:
future,
httr,
knitr,
shinytest,
testthat (>= 2.0)
shinytest2,
testthat (>= 3.0)
VignetteBuilder:
knitr
biocViews:
Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
28 changes: 13 additions & 15 deletions tests/testthat/test-shiny.R
Original file line number Diff line number Diff line change
@@ -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()
})

0 comments on commit 4ad706b

Please sign in to comment.