You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error when server portion of app uses a non-namespaced internal function #296
I'm not sure if this is strictly a bug, perhaps it's more of a question of how to achieve this.
When developing a package, I have non-exported functions that go inside the server portion of a shiny app. When using shinytest2, I can successfully create an AppDriver with such an app, but when I try calling expect_values() on it, I get an error:
Error in `app_expect_values(self, private, ..., input = input, output = output,
export = export, screenshot_args = screenshot_args, name = name,
cran = cran)`: Shiny server returned 404 for values URL: http://127.0.0.1:7774/session/4efa4384338a8862356b36154eb4512c/dataobj/shinytest?w=&nonce=ee808e486&input=1&output=1&export=1&format=json&sortC=1
i Is `shiny::runApp(test.mode = TRUE)` enabled?
To reproduce:
In an R package, create a file R/foo.R with a function foo <- function() 5
Run usethis::use_testthat() to set up the standard {testthat} structure
In tests/testthat/test-foo.R write the following code:
Hopefully, if we can get testthat to load the local package (not yet implemented in {shinytest2}), you will not need to namespace the methods / objects to the local package.
Using ::: does get it to work, it's what I've been using everywhere so far. Although notice that only the call inside the server causes a failure -- calling foo() in the UI is ok.
Hopefully it would be fixed by loading the local package like you say.
Activity
schloerke commentedon Jan 5, 2023
Would your code work if you used
bar <- dean:::foo()?Related: #298
Hopefully, if we can get
testthatto load the local package (not yet implemented in{shinytest2}), you will not need to namespace the methods / objects to the local package.daattali commentedon Jan 5, 2023
Using
:::does get it to work, it's what I've been using everywhere so far. Although notice that only the call inside the server causes a failure -- callingfoo()in the UI is ok.Hopefully it would be fixed by loading the local package like you say.
add badge (shinytest2 issue with NS see: rstudio/shinytest2#296)
schloerke commentedon Nov 18, 2025
Given an R package, #402 added support for:
where
create_app()is in your package and returns Shiny app objectExplicitly test app that uses internal variable