Coverage for all files using karma and includeAllSources: true
See original GitHub issueHello,
I’m using a setup with karma+jasmine+babelify for testing, my directory structure looks like this:
├── src
│ ├── moduleA.js
│ └── moduleB.js
└── test
├── config
├── functional
└── unit
This is the karma.conf:
module.exports = (config) => {
config.set({
basePath: '../../',
frameworks: ['browserify', 'jasmine'],
files: [
'test/unit/**/*.test.js',
],
reporters: ['spec', 'coverage'],
preprocessors: {
'test/unit/**/*.test.js': ['browserify'],
},
browserify: {
debug: true,
transform: [['babelify', { plugins: ['istanbul'] }]],
},
coverageReporter: {
dir: 'dist/coverage/unit',
includeAllSources: true,
reporters: [
{ type: 'html' },
{ type: 'json', file: 'coverage.json' },
],
},
browsers: ['PhantomJS'],
singleRun: true,
});
};
I’d like to make use of includeAllSources: true option for coverageReporter but can not find a way to have instrumentation for all files in src/ dir.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Karma JS -- How to Include all All Sources? - Stack Overflow
It includes files specified by pattern to coverage statistic. ... You just need to add includeAllSources: true to your coverageReporter , the Reporter ......
Read more >Coverage reporter is asking for `lcov.info` file if ... - YouTrack
I'm using Intellij Idea + karma plugin to run karma tests. Namely, I want to run test coverage. The issue is that when...
Read more >How to get karma-coverage (istanbul) to check coverage of ALL ...
When I run karma, the coverage preprocessor & reporter run, but it only checks the files that already have specs written. I want...
Read more >Configuration File - Karma
All of the configuration options, which specify file paths, use the ... If true, Karma runs the tests inside the original window without...
Read more >istanbuljs/nyc - Gitter
We ended up with mocha, requiring babel-register, and using istanbul 1.0.0-alpha.2 with include-all-sources: true for code coverage.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same issue. But with
webpack
instead ofbrowserify
with the setup below.I tried to use the
includeAllSources: true
flag incoverageReporter
ofkarma.conf.js
, however the generated output doesn’t include the untested files. It appears that the similar problem could be solved withisparta-loader
(https://github.com/karma-runner/karma-coverage/issues/192) though I was under the impression thatisparta-loader
package is deprecated in favor ofbabel-plugin-istanbul
?What would be the proper setup for
babel-plugin-istanbul
in order to get theincludeAllSources
to work? Any suggestions would be appreciated.Here is the
.babelrc
Here is the lineup of the libraries in
package.json
:Here is the code snippet from
karma.conf.js
:@wezleytsai @joyfulelement @sontek @davidklassen there’s an approach outlined here, for covering all files using Karma:
https://github.com/istanbuljs/babel-plugin-istanbul/issues/105
For technologies other than Karma, there are various approaches to achieving coverage of untested files:
--all
flag, which will result in all files being covered.onCover
hook which can also be used to track coverage for all files. @marco-ramirez’s repo https://github.com/marco-ramirez/babel-plugin-istanbul-include-untested-example/blob/master/task/test.js#L13 provides a great example of how to do this.--all
functionality for various technologies.karma
so that there’s less fiddling with config inbabel-plugin-istanbul
? CC: @dignifiedquire?