After Upgrading to Angular 13 the tests with --code-coverage is failing
Asked Answered
R

2

21

After Upgrading to Angular 13 the tests which are run with --code-coverage are failing with error that some plugin is missing

I am using karma-coverage-istanbul-reporter on the karma.conf.js and this is causing some issue. I even replaced this with the default karma-coverage, but still seeing the same error

ng test waxion --no-watch --code-coverage --browsers ChromeHeadless
⠋ Generating browser application bundles (phase: setup)...20 11 2021 17:34:24.723:ERROR [reporter]: Can not load reporter "coverage", it is not registered!
  Perhaps you are missing some plugin?
⠙ Generating browser application bundles (phase: building)...20 11 2021 17:34:27.353:INFO [karma-server]: Karma v6.3.9 server started at http://localhost:9876/
20 11 2021 17:34:27.353:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
20 11 2021 17:34:27.353:ERROR [karma-server]: Error: Found 1 load error
    at Server.<anonymous> (/Users/waxion/test-project/node_modules/karma/lib/server.js:239:26)
    at Object.onceWrapper (events.js:421:28)
    at Server.emit (events.js:327:22)
    at Server.EventEmitter.emit (domain.js:486:12)
    at emitListeningNT (net.js:1352:10)
    at processTicksAndRejections (internal/process/task_queues.js:79:21)```
Rollmop answered 20/11, 2021 at 12:21 Comment(0)
P
57

I encountered the same issue after upgrading to Angular 13. Adding the Istanbul reporter compared to the Karma reporter solved my issue.

So simply add coverage-istanbul to your reporters.

For example:

 reporters: ['progress', 'kjhtml', 'coverage-istanbul'],
Poult answered 22/11, 2021 at 15:25 Comment(0)
C
-1

Install npm i -D karma-coverage Change the following from karma-coverage-istanbul-reporter to karma-coverage

plugins: [ ... 'karma-coverage', ..., ], coverageReporter: { ... }

Cottingham answered 6/7, 2022 at 18:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.