karma-remap-coverage

raw JSON →
0.1.5 verified Fri May 01 auth: no javascript deprecated

Karma reporter that remaps Istanbul coverage reports to original source code using source maps, enabling accurate coverage for transpiled languages like TypeScript, ES6/7 with Babel, or JSX. Currently at v0.1.5, last released in 2017, with no further updates. Works in watch mode and stores interim coverage in memory (via karma-coverage's 'in-memory' type) to avoid temporary files. Integrates with webpack and other bundlers that produce source maps. Alternatives: karma-coverage-istanbul-reporter, karma-typescript's built-in coverage.

error Error: No provider for "framework:remap-coverage"!
cause Karma plugin not loaded or misspelled in plugins array.
fix
Add 'karma-remap-coverage' to plugins list (note: not 'remap-coverage' without prefix).
error No coverage report generated. Check that coverageReporter type is 'in-memory'.
cause Missing coverageReporter.type: 'in-memory' or wrong reporter name.
fix
Add coverageReporter: { type: 'in-memory' } to karma config and ensure reporters includes 'coverage' and 'remap-coverage'.
error TypeError: Cannot read property 'remapCoverageReporter' of undefined
cause remapCoverageReporter config not defined or Karma version incompatibility.
fix
Add remapCoverageReporter object in karma config with at least one output format, e.g., remapCoverageReporter: { html: './coverage' }.
deprecated Package is unmaintained since 2017; no TypeScript 3+ or Babel 7+ compatibility guaranteed.
fix Migrate to karma-coverage-istanbul-reporter or use built-in coverage in karma-typescript.
gotcha Both karma-coverage and karma-remap-coverage must be included in plugins array.
fix Add both 'karma-coverage' and 'karma-remap-coverage' to plugins list in karma.conf.js.
gotcha coverageReporter.type must be 'in-memory', not other values like 'json', otherwise remap won't work.
fix Set coverageReporter: { type: 'in-memory' } and do not specify any other output from karma-coverage.
gotcha Source maps must be enabled in transpiler config (e.g., tsconfig.json sourceMap: true, webpack devtool), or remap will produce empty reports.
fix Ensure source maps are generated for your source files and passed to Karma.
npm install karma-remap-coverage
yarn add karma-remap-coverage
pnpm add karma-remap-coverage

Shows minimal Karma config to enable remapped coverage: set reporters, use in-memory coverage, and configure remap output.

// Install: npm install karma-remap-coverage karma-coverage --save-dev
// karma.conf.js
module.exports = function(config) {
  config.set({
    files: ['test/**/*.spec.ts'],
    preprocessors: { 'test/**/*.spec.ts': ['webpack', 'sourcemap', 'coverage'] },
    reporters: ['progress', 'coverage', 'remap-coverage'],
    coverageReporter: { type: 'in-memory' },
    remapCoverageReporter: { html: './coverage', 'text-summary': null },
    plugins: ['karma-coverage', 'karma-remap-coverage'],
    webpack: { devtool: 'inline-source-map' }
  });
};