karma-remap-coverage
Karma reporter that maps coverage to original non transpiled code (TypeScript, ES6/7, etc).
Build on top of karma-coverage
and remap-istanbul
- consumes coverage report for raw transpiled code and maps it to original files. Transpiler should generate inline source maps in order to make everything work.
Needs no temporary files nor npm post run scripts, works in auto watch mode generating report on every run.
##Configuration
- Enable inline source maps in your transpiler/compiler
- Configure karma config to use
karma-coverage
together with karma-remap-coverage
###TypeScript + webpack example
Karma config with alternative usage of karma-webpack
should look something like this:
karma.conf.js
module.exports = config => config.set({
webpack: {
ts: {
compilerOptions: {
sourceMap: false,
inlineSourceMap: true
}
}
},
preprocessors: {
'./entry-module.ts': ['coverage']
},
reporters: ['progress', 'coverage', 'remap-coverage'],
coverageReporter: {
type: 'in-memory'
},
remapCoverageReporter: {
html: './coverage/html',
cobertura: './coverage/cobertura.xml'
},
plugins: ['karma-coverage', 'karma-remap-coverage']
});