-
Notifications
You must be signed in to change notification settings - Fork 118
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
Coverage with modules (e.g. klmr/box) #491
Comments
I think you are generally better off using the namespace of a proper R package to handle imports and exports of R objects, even in shiny apps. However if you or other community members would be willing to work on this feature and it didn't require too much additional code to support we would certainly consider it. |
Thanks! We had many discussions at Appsilon about Shiny apps as R packages; we currently use box modules, as a single namespace provided by a package makes it quite hard to build a large app. I do hope to find time to work on this feature - coverage reports for our apps is something we'd really like to have 🙂 |
@kamilzyla Very interesting to hear that |
Hi @telegott! We did not find a way to use directories for structuring unit tests other than running |
@telegott There is a pending PR for recursive subdirectories in |
@kamilzyla The PR for this has been merged to main |
Background
We use klmr/box (previously we used wahani/modules) to structure the code of our Shiny apps. These packages bring a module/import system similar to what you can find in languages like Python, JavaScript (ES6+) or Java.
Each module has its own namespace and multiple modules can export objects with identical names. For example, we can have modules named
main.R
andsidebar.R
both of which exportui
andserver
objects. When using them in some other module, they can be referred to e.g. asmain$server
andsidebar$server
. This also works in our testthat unit tests - the test file itself imports the functions it needs to test.Unfortunately the covr package is not prepared for this kind of usage. The
file_coverage()
function just sources all files passed in thesource_files
argument, so any duplicate names in the modules clash and overwrite each other. The generated coverage report has files missing.Goal
We'd love to use covr to generate coverage report for our Shiny apps, but we find modules very important for structuring large apps, and these two tools are currently incompatible. I'd like to start a discussion - how can we change that?
I'm happy to provide more details, e.g. prepare a demo project.
The text was updated successfully, but these errors were encountered: