angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.72k stars 11.98k forks source link

After Upgrading to Angular 13, Test Run Fails at Start With Coverage Error #22090

Closed mylifeandcode closed 2 years ago

mylifeandcode commented 2 years ago

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

After upgrading to Angular 13, when I try to run ng test I get the following output:

Please provide a link to a minimal reproduction of the bug

https://github.com/mylifeandcode/workouttracker/tree/Angular13Upgrade/WorkoutTracker.UI/workout-tracker

Please provide the exception or error you saw

Can not load reporter "coverage", it is not registered!
  Perhaps you are missing some plugin?
\ Generating browser application bundles (phase: setup)...04 11 2021 10:13:51.919:WARN [karma]: No captured browser, open http://localhost:9876/
04 11 2021 10:13:51.940:INFO [karma-server]: Karma v6.3.4 server started at http://localhost:9876/
04 11 2021 10:13:51.941:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
04 11 2021 10:13:51.942:ERROR [karma-server]: Error: Found 1 load error
    at Server.<anonymous> (C:\DevForFun\workouttracker\WorkoutTracker.UI\workout-tracker\node_modules\karma\lib\server.js:239:26)
    at Object.onceWrapper (events.js:519:28)
    at Server.emit (events.js:412:35)
    at emitListeningNT (net.js:1365:10)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

Please provide the environment you discovered this bug in

Angular CLI: 13.0.1
Node: 14.18.0
Package Manager: npm 6.14.15
OS: win32 x64

Angular: 13.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1300.1
@angular-devkit/build-angular   13.0.1
@angular-devkit/core            13.0.1
@angular-devkit/schematics      13.0.1
@angular/cdk                    9.2.1
@angular/cli                    13.0.1
@schematics/angular             13.0.1
rxjs                            6.5.5
typescript                      4.4.4

Anything else?

I'm not sure if this is an Angular issue or an issue with the reporting plug-in, so I apologize if it's the latter. This functionality was working until the upgrade to Angular 13.

petebacondarwin commented 2 years ago

I have a feeling that this is related to the setup of karma... Let's transfer this to the CLI repository since it is more likely they will know what is going on, and I don't believe it is due to a change in the framework itself.

alan-agius4 commented 2 years ago

Hi,

I looks like you are still using the previously deprecated now removed coverage plugin.

The below should fix it.

     plugins: [
       require('karma-jasmine'),
       require('karma-chrome-launcher'),
       require('karma-jasmine-html-reporter'),
+      require('karma-coverage'),
-      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-angular/plugins/karma')
     ],
....
+    coverageReporter: {
+     dir: require('path').join(__dirname, '../coverage'),
+      subdir: '.',
+      reporters: [
+        { type: 'html' },
+        { type: 'text-summary' }
+        { type: 'lcovonly' }
+     ]
-    coverageIstanbulReporter: {
-      dir: require('path').join(__dirname, '../coverage'),
-      reports: ['html', 'lcovonly'],
-      fixWebpackSourcePaths: true
    },
npm install karma-coverage --dev
npm uninstall karma-coverage-istanbul-reporter
mylifeandcode commented 2 years ago

I'm so sorry! You're absolutely right. This is what I get for not taking care of deprecated dependencies sooner! Thanks, and my apologies again for the trouble.

damingerdai commented 2 years ago

i also met this issue. but i have a question that why not provide the schematics to help user to migrate from karma-coverage-istanbul-reporter to karma-coverage?

angular-automatic-lock-bot[bot] commented 2 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.