Update karma coverage reporting for use in Angular 11

— 1 minute read

If you upgraded to Angular 11 recently, you might have noticed that karma-coverage-istanbul-reporter has been deprecated.

It can simply be replaced with karma-coverage and by changing some things in karma.conf.js.

npm uninstall karma-coverage-istanbul-report
npm install karma karma-coverage

Update karma.conf.js:

  • by removing require require('karma-coverage-istanbul-report') and including require('karma-coverage');
  • changing coverageIstanbulReporter to coverageReporter;
  • and changing the reports parameter to reporters.

As reference I refer to the karma.conf.js template within Angular 11: https://github.com/angular/angular-cli/blob/v11.0.0/packages/schematics/angular/application/files/karma.conf.js.template.