How to use shinytest to test whether a download was successful (but not compare the downloaded file)

Hi Everyone,

Is there a way to use ShinyDriver$snapshotDownload in the shinytest package (or another method) to test whether or not the download is successful? I don't need a comparison of differences in the downloaded data/rmarkdown pdf file (and the rmarkdown file throws an error with shinytest comparisons anyway...).

I just want to test is whether any changes to the app cause the downloadHander to fails.

Apologies in advance if there's a clear solution - I didn't see anything in rstudio community and I can't find much documentation for shinytest (especially with regard to downloads).

1 Like

A hack-ish solution to this seems to be to use testthat to test whether the length of the app$snapshotDownload() output (a raw vector of a long length) is greater than a small value (like 100).

I used the format from mastering-shiny: Chapter 21 Testing | Mastering Shiny and included the following line in my short test.

There are probabl ymore elegant ways...

testthat::expect_gt(length(app$snapshotDownload("download")), 100)