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

Cannot run tests unless connected to internet #341

Open
hugo-pH opened this issue Jul 11, 2023 · 0 comments
Open

Cannot run tests unless connected to internet #341

hugo-pH opened this issue Jul 11, 2023 · 0 comments

Comments

@hugo-pH
Copy link

hugo-pH commented Jul 11, 2023

When not connected to internet (or when behind a proxy) tests cannot run because app$expect_values() returns an error. The error comes from app_httr_get:

library(shiny)
library(shinytest2)
#> Loading required package: testthat

ui <- fluidPage(
  textInput("name", "What is your name?"),
  actionButton("greet", "Greet"),
  textOutput("greeting")
)
server <- function(input, output, session) {
  output$greeting <- renderText({
    req(input$greet)
    paste0("Hello ", isolate(input$name), "!")
  })
}
shiny_app <- shinyApp(ui, server)

app <- AppDriver$new(shiny_app)
app$set_inputs(name = "Hugo")
app$click("greet")
app$expect_values()
#> Error in `app_httr_get()`:
#> ! Could not find Shiny server. Shiny app is no longer running
#> Backtrace:
#>     ▆
#>  1. └─app$expect_values()
#>  2.   └─shinytest2:::app_expect_values(...)
#>  3.     └─shinytest2:::app_httr_get(...)
#>  4.       └─shinytest2:::app_abort(self, private, "Could not find Shiny server. Shiny app is no longer running")
#>  5.         └─rlang::abort(..., app = self, call = call)

Created on 2023-07-11 with reprex v2.0.2

And this is actually due to the call to pingr::is_up to check if the server is running. By the default, pingr::is_up checks first if the computer is online (check_online = TRUE).

In my case, since I work behind a proxy, this means I cannot use shinytest2 at all. So shouldn't be pingr::is_up called with check_online = FALSE to prevent this situation?

I can create a pull request if needed.

Thanks for the great package!

(Edited to include reprex)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant