ReferenceError: Can't find variable: Pickr when running shinytest::recordTest()

39 views Asked by At

I am currently working on an RShiny App which became pretty big and hence I want to implement automated UI testing. I therefore tried to record my UI tests with recordTest() from the shinytest package. However, when I run shinytest::recordTest(), I get the error message "ReferenceError: Can't find variable: Pickr" (see attached image). I located the problem to be a colorPickr from the shinyWidgets package and it seems like it has something to do with a .js-File in the package, but I have no idea how to solve this problem.

Error Message

When running shinytest::recordTest(), I usually would expect that the app starts in a headless browser and I can record my tests. This works perfectly fine, when I disable the line of code where the colorPickr is defined. With the colorPickr, the above error occurs.

I tried to update my R version (unfortunately we are working with 3.6.0 currently) and updated all packages, which did not help. I also tried to install phantomJS and set my PATH variable to the phantomjs.exe. Did not help either (not sure if I did that correctly tbh).

The package versions I use are: shinytest_1.5.1, shinyWidgets_0.6.2, shiny_1.6.0

The error is reproducable with the following example app:

library(shiny)
library(shinyWidgets)
library(shinytest)


# Define UI for app that draws a histogram ----
ui <- fluidPage(

  # App title ----
  titlePanel("Hello Shiny!"),

  # Sidebar layout with input and output definitions ----
  sidebarLayout(

    # Sidebar panel for inputs ----
    sidebarPanel(

      # Input: Slider for the number of bins ----
      sliderInput(inputId = "bins",
                  label = "Number of bins:",
                  min = 1,
                  max = 50,
                  value = 30),
      colorPickr(
        inputId = "color",
        label = "Pick a color",
        selected = "blue" )



    ),

    # Main panel for displaying outputs ----
    mainPanel(

      # Output: Histogram ----
      plotOutput(outputId = "distPlot")

    )
  )
)

# Define server logic required to draw a histogram ----
server <- function(input, output) {

  output$distPlot <- renderPlot({

    x    <- faithful$waiting
    bins <- seq(min(x), max(x), length.out = input$bins + 1)

    hist(x, breaks = bins, col = "#007bc2", border = "white",
         xlab = "Waiting time to next eruption (in mins)",
         main = "Histogram of waiting times")

  })

}

shinyApp(ui, server)

To reproduce the error, run shinytest::recordTest().

Thanks in advance for any help!

0

There are 0 answers