Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: can't run tests in a shiny app inside a package #386

Open
pablo-rodr-bio2 opened this issue Apr 26, 2021 · 5 comments
Open

Bug: can't run tests in a shiny app inside a package #386

pablo-rodr-bio2 opened this issue Apr 26, 2021 · 5 comments

Comments

@pablo-rodr-bio2
Copy link

Hi
I'm trying to run a test with shinytest for a shiny app that lives inside an R package (from Bioconductor).
I can record the test but I can't run it.

This is my code from a clean session:


library(shinytest)
recordTest("~/curro/gsva-devel/GSVA/inst/shinyApp", loadTimeout = 1e+05)

This is the result in console:

Saved test code to /home/bort/curro/gsva-devel/GSVA/inst/shinyApp/tests/shinytest/mytest.R
Running mytest.R Query failed (500)----------------------
<html>

<head lang = "en">
  <title>An error has occurred</title>
</head>

<body>

<h1>An error has occurred!</h1>
<p>lexical error: invalid char in json text.
                                       NULL c("shiny.silent.error", "v
                     (right here) ------^
</p>

</body>
</html>
 
----------------------------------------
Error in httr_get(url) : Unable request data from server

This is the file created at "~/curro/gsva-devel/GSVA/inst/shinyApp/tests/shinytest/mytest.R"
(I load the shiny app, click on a couple of inputs and save the snapshot, I don't plot anything)

app <- ShinyDriver$new("../../", loadTimeout = 1e+05)
app$snapshotInit("mytest")

app$setInputs(`matrix1-matrixSourceType` = "varMatrix")
app$setInputs(`genes1-genesetSourceType` = "varGeneset")
app$setInputs(arg = "yes")
app$setInputs(`argumentsInput-kcdf` = "Poisson")
app$snapshot()

sessionInfo()

R Under development (unstable) (2020-10-29 r79387)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS:   /home/bort/R-devel/lib/libRblas.so
LAPACK: /home/bort/R-devel/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=es_ES.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=es_ES.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=es_ES.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] promises_1.2.0.1 shiny_1.6.0      shinytest_1.5.0 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6        compiler_4.1.0    bslib_0.2.4       later_1.2.0       jquerylib_0.1.3  
 [6] base64enc_0.1-3   tools_4.1.0       testthat_3.0.2    digest_0.6.27     jsonlite_1.7.2   
[11] lifecycle_1.0.0   debugme_1.1.0     png_0.1-7         rlang_0.4.10      rstudioapi_0.13  
[16] curl_4.3          fastmap_1.1.0     withr_2.4.2       webdriver_1.0.6   httr_1.4.2       
[21] sass_0.3.1        parsedate_1.2.1   showimage_1.0.0   R6_2.5.0          processx_3.5.1   
[26] rematch_1.0.1     pingr_2.0.1       callr_3.7.0       magrittr_2.0.1    ps_1.6.0         
[31] ellipsis_0.3.1    htmltools_0.5.1.1 rsconnect_0.8.17  assertthat_0.2.1  mime_0.10        
[36] xtable_1.8-4      httpuv_1.6.0      cachem_1.0.4      crayon_1.4.1   
@MohoWu
Copy link

MohoWu commented Dec 19, 2021

Hi, I got the same error in one of my tests. In my case it was due to having validate() returning a 'shiny.silent.error' within plotly::renderPlotly(). I replaced the plotly plot with ggplot2 and used shiny::renderPlot() and it passed the test.

So maybe it's worth checking if there's anywhere in your app that returns a silent error it's not working well with some third party functions?

@GitHunter0
Copy link

I'm having the same issue...
Thank you for the insight, @MohoWu .
However, I really need plotly, I cannot replace it with ggplot2, I wonder if there is a workaround for that.

@NikoloAz
Copy link

I am having the same issue as pablo, just the error which pops up is:
Running mytest.R Error in httr_get(url): Shiny app is no longer running.
Anyone knows the solution to it?

@gadenbuie
Copy link
Member

Hi all -- now that we have shinytest2, my first suggestion would be to see if you can migrate to the newer framework. There are a lot of reasons to do so that are outlined on the shinytest2 site.

That said, I'd be happy to look into this issue, but it would be difficult to do so without a reproducible example.

@NikoloAz
Copy link

Hi gadenbuie, thanks for your response. For now i can only use shinytest package and can not migrate to the newer shinytest2 framework. But the correction of the source code (namely correction of function httr_get - function) as in issue 387 - #387 was helpful with regard to my issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants