karma-runner / karma-runner/karma-coverage
Coverage configuration with fast run and debug
- Dominant language
- JavaScript
- Stars
- 771
- Forks
- 242
- PR merge metrics
- No merged PRs in 30d
Description
Related discussion https://github.com/karma-runner/karma/issues/630
As expected coverage slows down test run and makes debugging impossible.
The workaround is to maintain two configs - the first one with coverage configured, and the second without coverage.
To improve the situation, there is a feature that allows external integrations (e.g. IDE) to turn off `coverage` preprocessor by removing `coverage` reporter: https://github.com/karma-runner/karma-coverage/blob/v0.5.1/lib/preprocessor.js#L54
This feature has been using by IntelliJ integration until a configuration that need `coverage` preprocessor for test run has emerged: https://github.com/karma-runner/karma-coverage/blob/v0.5.1/examples/coffee/karma.conf.coffee
Now IntelliJ uses a new trick to perform "Run", "Debug" and "Run with Coverage" actions with single karma.conf.js. However, it expects one thing from users - they should remove `coverage` reporter if `coverage` preprocessor is not needed for test run (still common use case, IMO):
- "Run" and "Debug" actions will work as `coverage` reporter is not set in config (done by users)
- "Run with Coverage" will work because `coverage` reporter is added on-the-fly by IntelliJ integration (https://github.com/karma-runner/karma-intellij/blob/2f63c75ea451d25fb17346abf8813e611d5e94f7/lib/intellijCoverageReporter.js#L19).
The downsides of the current approach:
- Undiscoverable for users
- Coverage won't be gathered if tests are run outside of IntelliJ, e.g. in Terminal
It'd be appreciated if it would be possible to improve the situation. A possible solution could be changing current coffeescript recommended configuration by making it possible to run tests without required coverage preprocessor. Also that would speed up tests.
Thanks.
Contributor guide
Assessment
This issue has not been assessed yet.