karma-runner / karma-coverage

A Karma plugin. Generate code coverage.
MIT License
770 stars 247 forks source link

Infinite loop when adding reporters type `html` #352

Open cvlos opened 6 years ago

cvlos commented 6 years ago

Issue:

I wanted to get a report on both the console and in an output folder. However, when I add type: 'html', the tests goes into infinite loop.

Karma.config.js:

files: [
      {pattern: 'karma/karma.entry.js', watched: false},
],
reporters: ['progress', 'coverage', 'remap-coverage'],
remapCoverageReporter: {
      'text-summary': null,
},
coverageReporter: {
      dir: './coverage',
      reporters: [
        {type: 'text'},
        {type: 'html', subdir: 'html'},
      ],
},
plugins: [
      istanbul-instrumenter-loader',
      'karma-chrome-launcher',
      'karma-coverage',
      'karma-jasmine',
      'karma-sourcemap-loader',
      'karma-webpack',
      'karma-remap-coverage',
]
...

Any ideas?

weibinzhu commented 5 years ago

same here. in fact if you set your coverage output directory to somewhere outside your 'watch files directory', you will fix it.

weibinzhu commented 5 years ago

I finally figure it out. It's because I used webpack's require.context in my 'karma.entry.js' files. every time a new coverage html report is generated, webpack will detect some files are created or deleted and trigger a 'recompile'