Closed shalutiwari closed 4 years ago
I'm getting a similar error:
> shinytest::testApp("~/myApp/", "myTest1")
Running myTest1.R Error: lexical error: invalid char in json text.
<h1>Not Found</h1>
(right here) ------^
But I don't get it when I run interactively using:
app <- ShinyDriver$new(".", loadTimeout = 200000)
app$snapshotInit("myTest1")
app$takeScreenshot(file = "beforeClick.png")
Session Info:
R version 4.0.0 (2020-04-24)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 LC_MONETARY=en_CA.UTF-8
[6] LC_MESSAGES=en_CA.UTF-8 LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] tools stats4 parallel grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] tictoc_1.0 furrr_0.1.0 shinyEventLogger_0.1.1 xml2_1.3.2 httr_1.4.1 lubridate_1.7.8
[7] mongolite_2.2.0 dbplyr_1.4.3 pool_0.1.4.3 future.apply_1.5.0 future_1.17.0 promises_1.1.0
[13] shinyjs_1.1 readr_1.3.1 dtplyr_1.0.1 purrr_0.3.4 shinyWidgets_0.5.2 shinyFeedback_0.2.0.9000
[19] shinythemes_1.1.2 DT_0.13 tibble_3.0.1 Biostrings_2.56.0 XVector_0.28.0 IRanges_2.22.1
[25] S4Vectors_0.26.0 BiocGenerics_0.34.0 ggvis_0.4.5 magrittr_1.5 stringr_1.4.0 shinyBS_0.61
[31] foreach_1.5.0 dplyr_0.8.5 rhandsontable_0.3.7 ggplot2_3.3.0 stringi_1.4.6 RMySQL_0.10.20
[37] DBI_1.1.0 tidyr_1.1.0 shinydashboard_0.7.1 openxlsx_4.1.5 readxl_1.3.1 shiny_1.4.0.9003
[43] shinytest_1.3.1.9003
loaded via a namespace (and not attached):
[1] colorspace_1.4-1 ellipsis_0.3.1 rsconnect_0.8.16 base64enc_0.1-3 rstudioapi_0.11 listenv_0.8.0 bit64_0.9-7
[8] fansi_0.4.1 codetools_0.2-16 R.methodsS3_1.8.0 jsonlite_1.6.1 bupaR_0.4.3 packrat_0.5.0 rematch_1.0.1
[15] png_0.1-7 R.oo_1.23.0 data.tree_0.7.11 compiler_4.0.0 assertthat_0.2.1 fastmap_1.0.1 cli_2.0.2
[22] later_1.0.0 htmltools_0.4.0.9003 gtable_0.3.0 glue_1.4.1 Rcpp_1.0.4.6 cellranger_1.1.0 webdriver_1.0.5
[29] vctrs_0.3.0 debugme_1.1.0 iterators_1.0.12 crosstalk_1.1.0.1 globals_0.12.5 ps_1.3.3 testthat_2.3.2
[36] mime_0.9 parsedate_1.2.0 miniUI_0.1.1.1 lifecycle_0.2.0 zlibbioc_1.34.0 scales_1.1.1 hms_0.5.3
[43] RMariaDB_1.0.8 yaml_2.2.1 curl_4.3 pingr_2.0.0 zip_2.0.4 rlang_0.4.6 pkgconfig_2.0.3
[50] bitops_1.0-6 htmlwidgets_1.5.1 bit_1.1-15.2 processx_3.4.2 tidyselect_1.1.0 showimage_1.0.0 R6_2.4.1
[57] helfRlein_0.3.1 generics_0.0.2 pillar_1.4.4 eventdataR_0.2.0 withr_2.2.0 RCurl_1.98-1.2 crayon_1.3.4
[64] data.table_1.12.8 callr_3.4.3 forcats_0.5.0 digest_0.6.25 xtable_1.8-4 httpuv_1.5.2 R.utils_2.9.2
[71] openssl_1.4.1 munsell_0.5.0 askpass_1.1
I had to work around this by explicitly specifying which objects to include in the snapshot.
@shalutiwari where can 026-shiny-inline
be found?
This seems to occur when the subprocess server returns an error message, in my case:
Browse[2]>
debug: req <- httr::GET(url)
Browse[2]>
debug: if (private$snapshotCount == 1) {
if (dir_exists(current_dir)) {
unlink(current_dir, recursive = TRUE)
}
dir.create(current_dir, recursive = TRUE)
}
Browse[2]>
debug: content <- raw_to_utf8(req$content)
Browse[2]>
debug: content <- hash_snapshot_image_data(content)
Browse[2]> content
[1] "<html>\n\n<head>\n <title>An error has occurred</title>\n</head>\n\n<body>\n\n<h1>An error has occurred!</h1>\n<p>in 'x[[151]]': not a base at pos 19</p>\n\n</body>\n</html>\n"
Browse[2]> cat(content)
<html>
<head>
<title>An error has occurred</title>
</head>
<body>
<h1>An error has occurred!</h1>
<p>in 'x[[151]]': not a base at pos 19</p>
</body>
</html>
Browse[2]>
The code needs to check for a returned error code instead of assuming the results are proper JSON.
I've added code to fix this issue to PR #324.
I can't reproduce the error:
library(shinytest)
app <- ShinyDriver$new("../shiny-examples/026-shiny-inline/index.Rmd")
str(app$getAllValues())
But I'm almost certain it's the same root cause as #191 or #192, which I'm about to fix momentarily.
Getting below error when running testapp on terminal: