如何解决R - 当表使用 hot_validate_* 时使用带有 rhandsontable 的 Shinytest
我正在尝试为使用 rhandsontable 的闪亮应用程序创建自动化测试。 rhandsontable 使用 hot_validate_numeric 函数,当通过 Shinytest 运行应用程序时, rhandsontable 不会呈现(当我尝试截取正在运行的应用程序的屏幕截图时),如果我在应用程序中调用任何依赖于所述 rhot 表的计算,应用程序崩溃。
一个简单的可重现示例,其中我将 mtcars
显示为 rhot 表,以及一个使用 rhot 表中的数据计算 mpg 平均值的按钮。
library(shiny)
library(rhandsontable)
# Define UI for application that draws a histogram
ui <- fluidPage(
titlePanel("Test"),fluidRow(column(12,rHandsontableOutput("input_table"))),actionButton("button","Compute MPG Mean"),textoutput("mean")
)
# Define server logic required to draw a histogram
server <- function(input,output) {
output$input_table <- renderRHandsontable(
rhandsontable(mtcars) %>% hot_validate_numeric("mpg",min = 0,max = 40)
)
observeEvent(
input$button,{
n = mean(hot_to_r(input$input_table)$mpg)
output$mean = renderText(n)
}
)
}
# Run the application
shinyApp(ui = ui,server = server)
现在,如果我按以下方式运行测试,应用程序会崩溃:
app <- ShinyDriver$new("path/to/app")
app$takeScreenshot() # rhot table does not appear in this
app$setInputs(button = "click")
# I get a message saying : Server did not update any output value within 3 seconds
# And if take another screenshot of app,I can see the app has crashed.
该应用程序正常运行,仅在使用 Shinytest 时才会失败。如果我删除 hot_validate_numeric,那么 Shinytest 也能工作。
有什么方法可以让我在使用 hot_validate_numeric 的同时还能运行测试吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。