-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Strategy for testing examples with interactive app #1047
Comments
I was wondering if it's possible to have an app start and kill itself after, say a second or two. That way an automated pipeline could actually run all all the apps but not capture the session indefinitely. Anyway, I think the answer may lie in what @vedhav has been cooking up. |
@pawelru do check this draft PR which does a very similar thing but with cypress to do the integration tests. In fact, this helped in capturing an actual bug which is somewhere in It follows these steps to do the tests:
P.S this is also part of a larger testing conversation |
When working on strict testing (incl. examples) I came up with mocking |
I'm going to close it not to duplicate the space for discussion. Let's move it to the linked issue. |
How about creating a new issue to leverage
However, we do have the options as the diff below passes diff --git a/R/init.R b/R/init.R
index 01af3c0ee..52391d08a 100644
--- a/R/init.R
+++ b/R/init.R
@@ -88,9 +88,9 @@
#' header = tags$h1("Sample App"),
#' footer = tags$p("Copyright 2017 - 2023")
#' )
-#' if (interactive()) {
-#' shinyApp(app$ui, app$server)
-#' }
+#' \dontshow{if (interactive()) \{ # is interactive }
+#' shinyApp(app$ui, app$server)
+#' \dontshow{ \} # is interactive }
#'
init <- function(data,
modules, |
The parts in |
Most of our app examples looks like this:
When checking the code, only
app
variable will be initiated and we do not (!) run the app which will cover server code. It's like defining the function vs executing it. As a result our examples might fail and this already happened (e.g. #1046). We need to came up with the strategy how to prevent it.I have an idea to use
\dontshow{}
roxygen2 syntax to put some basic tests to cover server codes against some obvious mistakes. It won't be included in the final docs but it will be run during check (see the docs). In there, we might useshinytest2
to and put some basic tests. If there will be a lot of overhead code - we can create an utility function. Just an idea - haven't really tried this (will do it tomorrow).Please let me know your thoughts on this.
This might be relevant for modules packages as well.
The text was updated successfully, but these errors were encountered: