rstudio / shinytest2

https://rstudio.github.io/shinytest2/
Other
108 stars 18 forks source link

Use `local_mocking_bindings` from {testthat} or how change function bindings with {shinytest2} #371

Open Fideldue opened 11 months ago

Fideldue commented 11 months ago

{Testthat} now also includes the possibility to mock functions via with_mocking_bindings/local_mocking_bindings. This doesn't work with {shinytest2} when trying to setup a mock before calling AppDriver$new(), the mocked function is still returning the original values. Is this connected to https://github.com/rstudio/shinytest2/issues/301 and in general not possible currently?

If yes, is there a workaround to change some function bindings for AppDriver?

Basically, I want to mock external data connectors (e.g. database connections or directly the data via fixtures), which are used by the application without adding some conditional test files/function outputs in the productive code.

Happy to hear I missed something or open to discuss any ideas to contribute.

Fideldue commented 6 months ago

Any news or ideas on that?