rstudio / shinytest

Automated testing for shiny apps
https://rstudio.github.io/shinytest/
Other
225 stars 55 forks source link

Setting a date input to empty string breaks test #374

Open nstrayer opened 3 years ago

nstrayer commented 3 years ago

Summary

Shinytest breaks when a date input is set to nothing

Info

Using shinytest::recordTest() with an app with a date input and then setting that date input to empty by simply erasing the date string with the delete key will break the test when it tries to run. The error message is:

Listening on http://127.0.0.1:3397
C> Loading required package: shiny
C> Running application in test mode.
C> 
C> Listening on http://127.0.0.1:5259
Saved test code to /Users/nick/Desktop/break_date_input/tests/mytest.R
Running mytest.R Error in session_makeRequest(self, private, endpoint, data, params, headers) : 
  undefined is not a constructor (evaluating 'e.replace(/-/g,"/")')

To reproduce

app.R: Basic app with a date input

library(shiny)
shinyApp(ui = fluidPage(dateInput("date", "")), server = function(input, output, session) {})

mytest.R: Generated test script from running shinytest::recordTest() and then erasing date and taking a snapshot.

app <- ShinyDriver$new("../")
app$snapshotInit("mytest")

app$setInputs(date = character(0))
app$snapshot()