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
Within a Shiny app, I'm sourcing a file with all my functions, and I'm using testthat to test these. It's all good until I need to do some mocking and I can't quite figure out how to use the new functions with_mocked_bindingsand local_mocked_bindings.
test_that("Mocking a function works",{
local_mocked_bindings(my_function = mocked_fn)
expect_equal(my_function(), 1)
})
Unfortunately I keep running into Error in 'dev_package()': No packages loaded with pkgload. My sort of suspicion here is that these two functions can only work from within a package environment.
Is my understanding correct ? If so would there be a way of achieving my goal ?
Thanks ahead of time for the support !
The text was updated successfully, but these errors were encountered:
Yeah, those functions only work inside a package sorry. I think the easiest way to solve your problem would be to put your R scripts in R/ directory and your tests in tests/testthat/ directory and add a minimal DESCRIPTION 😄
Hello,
Within a Shiny app, I'm sourcing a file with all my functions, and I'm using
testthat
to test these. It's all good until I need to do some mocking and I can't quite figure out how to use the new functionswith_mocked_bindings
andlocal_mocked_bindings
.Assuming I have the following functions :
I'd expect this test to succeed :
Unfortunately I keep running into
Error in 'dev_package()': No packages loaded with pkgload
. My sort of suspicion here is that these two functions can only work from within a package environment.Is my understanding correct ? If so would there be a way of achieving my goal ?
Thanks ahead of time for the support !
The text was updated successfully, but these errors were encountered: