rstudio / shinytest

Automated testing for shiny apps
https://rstudio.github.io/shinytest/
Other
225 stars 55 forks source link

package check with shinytest and testthat #362

Closed DavidFingerKB closed 4 years ago

DavidFingerKB commented 4 years ago

Hello,

first of all, great package!

I am currently working on a project with shiny and we are having trouble getting the package check to work with testthat and shinytest. You can find a minimal example project here: https://github.com/DavidFingerKB/Shinytest

There is a test in tests/testthat/test-mean.R using testthat and there is a shiny test in tests/testthat/test-shinytest_app.R also using shinytest. Running each testscript alone works fine. Running a package check with both tests included does not work, in that case there is an error. When excluding tests/testthat/test-shinytest_app.R from the package check, it runs fine again.

We are currently using the following versions: R 4.0.2 RStudio 1.3.1056 Shiny 1.5.0 shinytest 1.4.0

But the same problem also seemed to be the case earlier R versions.

The folder structure in the example package is exactly how we are using it in a larger project. It would be great, if we could use both testthat and shinytest with our current setup.

If you need any other information, just let me know. Any help is greatly appreciated!

Best regards David Finger

hadley commented 4 years ago

I think you should wait a couple of weeks for all of the pieces to come together, and then use the approach described in https://mastering-shiny.org/scaling-testing.html

DavidFingerKB commented 4 years ago

Thank you very much for your response!

Just so we know what to look for, what do you think will make a difference in the testing process? E.g. should we check for updates in the testthat and shinytest packages in the next weeks?

hadley commented 4 years ago

All the pieces are there now; it's more that the description in the chapter is still coming together.

earnaud commented 3 years ago

Hi ! I am experiencing a case that I do not find covered elsewhere: I am building a shiny app in a package. Testing the app manually correctly loads everything with golem::document_and_reload() but this does not happen with {shinytest}. I get :

x <- shinytest::ShinyDriver$new(
+         "R/"
+       )
Error: Shiny app did not load in 5000ms.
S/I 11:14:50.00 window.shinytest loaded
S/I 11:14:50.00 jQuery not loaded yet
C/E ----------- Loading required package: shiny
C/E ----------- Running application in test mode.
C/E ----------- 
C/E ----------- Listening on http://127.0.0.1:4238
C/E ----------- Warning: Error in devmsg: could not find function "devmsg"
C/E -----------   82: ui [/home/pndb-elie/Softwares/Gits/MetaShARK-v2/R/ui.R#18]

I tried to add @include for correct files in roxygen documentation, but it does not change anything. Do I forget something?