Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the unit test and move to shinytest2 #224

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
})
Loading