karma-runner / karma-runner/karma-coverage

includeAllSources doesn't work with webpack and babel-plugin-__coverage__

Open
#249 4 comments 8 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
771
Forks
242
PR merge metrics
No merged PRs in 30d

Description

By supplying the `includeAllSources: true` flag in `coverageReporter` of `karma.conf.js`, the generated output doesn't include the untested files with the following setup. This maybe related to #192 , but with the different instrumenter `babel-plugin-__coverage__` being used here.

Does anyone had similar experience for how to include untested files in the result and manage to get it to work with `babel-plugin-__coverage__`?
Thanks

Here is the `.babelrc`

```
{
...
"env": {
"test":{
"plugins": [
["__coverage__", {"ignore": "*.+(spec|mock).*"}]
]
}
}
}
```

Here is the lineup of the libraries in `package.json`:

```
...
"babel-plugin-__coverage__": "11.0.0",
"karma": "1.1.1",
"karma-chrome-launcher": "1.0.1",
"karma-cli": "1.0.1",
"karma-coverage": "1.1.1",
"karma-firefox-launcher": "1.0.0",
"karma-jasmine": "1.0.2",
"karma-sourcemap-loader": "0.3.7",
"karma-spec-reporter": "0.0.26",
"karma-webpack": "1.7.0",
"webpack": "1.13.1",
...
```

Here is the code snippet from `karma.conf.js`:

```
config.set({
...
preprocessors: {
'../../src/js/**/*.js': [ 'webpack', 'sourcemap' ],
'../../src/js/**/*.jsx': [ 'webpack', 'sourcemap' ],
'../../src/js/**/__tests__/*spec.js': [ 'webpack', 'sourcemap' ],
'../../src/js/**/__tests__/**/*spec.js': [ 'webpack', 'sourcemap' ]
},

webpack: {
module: {
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loaders: [ 'babel-loader' ] //babel loads jsx and es6-7
},
{ test: /\.json$/, loader: 'json-loader' }
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.IgnorePlugin(/^fs$/)
],
devtool: 'cheap-module-eval-source-map'
},

reporters: [ 'spec', 'coverage' ],

coverageReporter: {
reporters: [
{ type: 'html', dir: 'coverage/', subdir: 'report-html', includeAllSources: true },
{ type: 'cobertura', dir: 'coverage/report-cobertura/', file: 'cobertura.txt', includeAllSources: true },
{ type: 'text-summary', includeAllSources: true }
]
},
...
})
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.