Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
I having a weird behaviour when the reporter shows me the branch coverage else-statement even if this code is under cover by my tests.
The problem it's that always shows a else branch coverage in the same line ... even if i swap the lines!!
My config is the following:
karma.conf.js
var webpack = require('webpack');
module.exports = function(config) {
var wsPort = process.env.wsPort || 8000;
var webpackConfig = Object.assign({}, config.webpack, {
plugins: config.webpack.plugins.concat([
new webpack.SourceMapDevToolPlugin({
filename: null,
test: /\.js/i
})
]),
module: Object.assign({}, config.webpack.module, {
postLoaders: (config.webpack.module.postLoaders || []).concat([{
test: /\.js$/,
exclude: /(test|node_modules|bower_components)\//,
loader: 'istanbul-instrumenter',
options: {
compact: false
}
}])
}),
// Esto es necesario porque karma-webpack muta el output, causando un error al correr junto con start-main-server
output: Object.assign({}, config.webpack.output),
entry: undefined
});
return {
files: [
{ pattern: 'test/unit/test-main.js', watched: false }
],
preprocessors: {
'test/unit/test-main.js': ['webpack', 'sourcemap']
},
webpack: webpackConfig,
webpackMiddleware: {
stats: 'errors-only'
},
frameworks: ['mocha', 'chai', 'chai-as-promised', 'sinon', 'sinon-chai'],
browsers: [],
proxies: {
'/ws/': 'http://localhost:' + wsPort + '/ws/',
},
client: {
mocha: {
reporter: 'html' // change Karma's debug.html to the mocha web reporter
}
},
singleRun: false,
plugins: [
'karma-webpack',
'karma-mocha',
'karma-mocha-reporter',
'karma-chai-plugins',
'karma-sinon',
'karma-phantomjs-launcher',
'karma-sourcemap-loader',
'karma-coverage-istanbul-reporter',
'karma-junit-reporter'
]
};
};
karma.coverage.js (I load this configuration in a separated file using gulp)
I having a weird behaviour when the reporter shows me the branch coverage else-statement even if this code is under cover by my tests. The problem it's that always shows a else branch coverage in the same line ... even if i swap the lines!!
My config is the following:
karma.conf.js
karma.coverage.js (I load this configuration in a separated file using gulp)
I attached multiple screenshoots showing this.
Check this out images that show that if i swap the lines, the else branch it is showed always on the same line