karma-coverage
karma-coverage copied to clipboard
coverage report includes actual tests
The issue I am having is that the coverage report counts the actual test spec files. Thus, the total lines covered is significantly skewed. What do I have to change in the coverageReporter config to specify paths to ignore in the coverage report without having it not run the tests themselves?
Happy to provide a sample of my config or other info if need be.
thanks!
I also have this issue as I have my test files along side the source code rather than in their own directory.
https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md#check
Check the 'excludes' array here, that should do what you're talking about. While it excludes these files from the total %, I still haven't figured out how to get those files to not display in the table that's printed out when I use type 'text'. Hope this helps you out a little bit at least, though
@meg2208 make sure your patter for preprocessing src file does not include any test files:
preprocessors: { 'src/**/*.js': ['coverage'] },
Post your preprocessors config here, along with paths to source files and test files in your project.
I'm also seeing the issue. Coverage includes test files and source files.
Path to source file: src
Path to test files: browser-test
Here is my config file:
module.exports = function(config) {
config.set({
browsers: ['Safari', 'Chrome', 'Firefox'],
files: ['browser-test/**/*.js'],
frameworks: ['browserify', 'mocha', 'events'],
preprocessors: {
'browser-test/**/*.js': ['browserify'],
'src/**/*.js': ['coverage'],
},
reporters: ['mocha', 'coverage'],
singleRun: true,
browserify: {
debug: true,
transform: [
['babelify', {
"babelrc": false,
"plugins": [
"istanbul"
],
"presets": [
["@babel/env", {
"targets": {
"firefox": 60
}
}]
]
}]
]
},
coverageReporter: {
type : 'lcov',
dir : 'coverage/',
includeAllSources: true
},
client: {
mocha: {
grep: '@nodeonly',
invert: true
}
},
events: {
events: {
run_start: 'npm run start-test-server',
run_complete: 'npm run stop-test-server'
}
}
});
};