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 (将#修改为@)