Search code examples
angulartestingjasminekarma-runnertsconfig

How can I set the ng test code-coverage directory?


I'm running $ ng test -cc and using the coverage report nicely.

However, it appears in the src folder, which is skewing the results of Find in the src folder, which should just be the source folder, is there a way I can specify the desired location of the generated coverage directory, in tsconfig.spec.json or karma.conf.js perhaps?


Solution

  • karma-coverage-istanbul-reporter is responsible for those settings.

    karma.conf.js

    const path = require('path');
    
    module.exports = function (config) {
      config.set({
        ...
        coverageIstanbulReporter: {
           reports: ['html', 'lcovonly'],
           fixWebpackSourcePaths: true,
           dir: path.join(__dirname, 'coverage2') <== this option
        },