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
Request: Starting AppDriver in a custom URL for testing bookmarking #219
Comments
For now, you can start your app in a background process and provide the url directly. Something like.. # Untested code!
# Start app in background process given the port value
port <- httpuv::randomPort()
app_bg <- callr::r_bg(
function(port) {
appObject <- make_app_object()
shiny::runApp(
appObject,
port = port,
test.mode = TRUE
)
},
list(port = port),
stderr = "|"
)
withr::defer({ app_bg$kill() })
# Wait until the app is ready
for (i in 1:100) {
if (pingr::is_up("127.0.0.1", 12345)) {
break
}
Sys.sleep(0.2)
}
# Create bookmark url
app_url <- paste0("http://127.0.0.1:", port, "/?inputs_n=10")
# Use url value
app <- appDriver$new(app_url)
# Test like normal While not as easy as a parameter, it can be wrapped up into a method. Will probably need to adjust the |
Thanks a lot! |
Maybe a simpler solution for this problem could be: (notice I have corrected some typos in the URL from the previous response)
This delegates all the app launching process to Unfortunately, this (as well as the approach proposed in #219 (comment)) has the following problem:
This breaks any attempt to include bookmarking parameters in the url. I was able to pinpoint the problem to: Line 60 in 29c7a6b
I will report this in a different issue that links here to separate it from this enhancement request. |
What a wonderful solution! bg_app <- shinytest2::AppDriver$new(app_dir = "my/shiny/app")
bg_app_url <- bg_app$get_url()
app<- shinytest2::AppDriver$new(paste0(bg_app_url, "?_inputs_&n=10")) With this not being too terrible to have the user implement, (for now) I'm going to just make it a FAQ entry with your solution. |
The issues with |
Hi all, I have not yet found a direct way of testing bookmarking. This is relevant when creating modules that you want to guarantee will save and restore bookmarks correctly.
One possibility would be to include a parameter in the
AppDriver$new
method:The text was updated successfully, but these errors were encountered: