How would you test that a shiny app is deployed? I thought of using Rcurl::url.exists() which works if the app is runnin, but not if it's sleeping. For example:
> library(testthat)
> expect_equal(
+ TRUE
+ )
1 element mismatch
> options(width = 120)
> devtools::session_info()
Session info -----------------------------------------------------------------------------------------------------------
setting value
version R version 3.3.0 RC (2016-05-01 r70572)
system x86_64, darwin13.4.0
ui AQUA
language (EN)
collate en_US.UTF-8
tz America/New_York
date 2016-07-13
Packages ---------------------------------------------------------------------------------------------------------------
package * version date source
bitops 1.0-6 2013-08-17 CRAN (R 3.3.0)
crayon 1.3.2 2016-06-28 CRAN (R 3.3.0)
devtools 1.12.0 2016-06-24 CRAN (R 3.3.0)
digest 0.6.9 2016-01-08 CRAN (R 3.3.0)
magrittr 1.5 2014-11-22 CRAN (R 3.3.0)
memoise 1.0.0 2016-01-29 CRAN (R 3.3.0)
R6 2.1.2 2016-01-26 CRAN (R 3.3.0)
RCurl 1.95-4.8 2016-03-01 CRAN (R 3.3.0)
testthat * 1.0.2 2016-04-23 CRAN (R 3.3.0)
withr 1.0.2 2016-06-20 CRAN (R 3.3.0)
Interactively, I can force the app to be running by using utils::browseURL() first, but that won't work when testing in a non-interactive environment. Such as with:
if(interactive()) {
## Open shiny app when running test in interactive mode.
## This will force the app to be available, which will then run the test
## successfully.
test_that('Shiny app is up', {
expect_equal(
TRUE
)
})
}