Hello
I've encountered an error whilst testing:
Error in `app_expect_values(self, private, ..., input = input, output = output,
export = export, screenshot_args = screenshot_args, name = name,
cran = cran)`: Shiny server returned 404 for values URL: http://127.0.0.1:5711/session/bc777a48fd9d472a3a1f837f1ece2d67/dataobj/shinytest?w=&nonce=c7e7d7b16&input=1&output=1&export=1&format=json&sortC=1
ℹ Is `shiny::runApp(test.mode = TRUE)` enabled?
Backtrace:
▆
1. └─app$expect_values() at test-shinytest2.R:16:2
2. └─shinytest2:::app_expect_values(...)
3. └─shinytest2:::app_httr_get(...)
4. └─shinytest2 (local) fn_404(req)
5. └─shinytest2:::app_abort(...)
6. └─rlang::abort(..., app = self, call = call)
I've managed to establish that it's caused by an interaction between my use of gargoyle and leaflet.extras. When the app either contains leaflet.extras::addDrawToolbar without gargoyle everything is fine, and similarly if I create a simple app using just gargoyle everything works fine. Here's an MRE and the test which fails to run: (what was extra confusing, is that I encountered this on my first use of shinytest2 and so I spent hours trying to enable test.mode = TRUE)
library(shiny)
library(leaflet)
library(leaflet.extras)
library(gargoyle)
shiny_app <- shinyApp(
fluidPage(
leafletOutput("map",width=500,height=500),
verbatimTextOutput("coords")
),
function(input, output) {
output$map <- renderLeaflet(
leaflet() %>%
setView(0, 0, zoom = 2) %>%
addProviderTiles('Esri.WorldTopoMap') %>%
addDrawToolbar(polylineOptions=F,circleOptions = F, rectangleOptions = T, markerOptions = F, circleMarkerOptions = F, singleFeature = T,polygonOptions = F)
)
common_class <- R6::R6Class(
classname = "common",
public = list(
poly = NULL
)
)
gargoyle::init("change_poly")
common <- common_class$new()
observe({
coords <- unlist(input$map_draw_new_feature$geometry$coordinates)
xy <- matrix(c(coords[c(TRUE,FALSE)], coords[c(FALSE,TRUE)]), ncol=2)
colnames(xy) <- c('longitude', 'latitude')
common$poly <- xy
gargoyle::trigger("change_poly")
}) %>% bindEvent(input$map_draw_new_feature)
output$coords <- renderText({
common$poly}) %>% bindEvent(gargoyle::watch("change_poly"))
}
)
test_that("{shinytest2} recording: testing_bug", {
app <- AppDriver$new(name = "testing_bug", height = 909, width = 1379)
app$set_inputs(map_groups = "editableFeatureGroup", allow_no_input_binding_ = TRUE)
app$set_inputs(map_draw_start = "rectangle", allow_no_input_binding_ = TRUE)
app$set_inputs(map_draw_new_feature = c("Feature", 76, "rectangle", "Polygon",
c(c(2.460938, 18.312811), c(2.460938, 28.921631), c(15.820313, 28.921631),
c(15.820313, 18.312811), c(2.460938, 18.312811))), allow_no_input_binding_ = TRUE)
app$set_inputs(map_draw_all_features = c("FeatureCollection", c("Feature", 76,
"rectangle", "Polygon", c(c(2.460938, 18.312811), c(2.460938, 28.921631), c(15.820313,
28.921631), c(15.820313, 18.312811), c(2.460938, 18.312811)))), allow_no_input_binding_ = TRUE)
app$set_inputs(map_draw_stop = "rectangle", allow_no_input_binding_ = TRUE)
app$set_inputs(map_click = c(18.3128108464255, 15.8203125, 0.384901733059819),
allow_no_input_binding_ = TRUE)
app$expect_values()
})
Hello
I've encountered an error whilst testing:
I've managed to establish that it's caused by an interaction between my use of
gargoyleandleaflet.extras. When the app either containsleaflet.extras::addDrawToolbarwithoutgargoyleeverything is fine, and similarly if I create a simple app using justgargoyleeverything works fine. Here's an MRE and the test which fails to run: (what was extra confusing, is that I encountered this on my first use ofshinytest2and so I spent hours trying to enabletest.mode = TRUE)