Skip to content

Angular v11 ignores karma plugin config karma-* and throws error #19993

Closed
@iftee-hussain

Description

@iftee-hussain

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

karma-coverage was made required in angular 11 and strict checking of karma-coverage was also introduced in v11. So, no it is not a regression

Description

According to https://karma-runner.github.io/6.1/config/configuration-file.html

List of plugins to load. A plugin can be a string (in which case it will be required by Karma) or an inlined plugin - Object. By default, Karma loads all sibling NPM modules which have a name starting with karma-*.

I have added karma-coverage in package.json and installed it
and added karma-* to the plugins config in karma.conf.js
Angular cli ignores the installed package as it seems karma-* config is ignored while validating karma-coverage is installed
It works when in plugins configuration one of these is added
'karma-coverage' or require('karma-coverage')

🔬 Minimal Reproduction

  1. Add karma-coverage in package.json and install it (npm install)
"karma-coverage": "^2.0.3",
  1. Add 'karma-*' in karma.conf.js . Example:
plugins: [
      'karma-*',
      require('@angular-devkit/build-angular/plugins/karma'),
    ]
  1. Run tests ng test

🔥 Exception or Error



 ERROR [karma-server]: Server start failed on port 9876: Error: karma-coverage must be installed in order to run code coverage.

🌍 Your Environment




     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 11.1.1
Node: 12.16.1
OS: linux x64

Angular: 11.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router, upgrade
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1001.7
@angular-devkit/build-angular   0.1100.7
@angular-devkit/core            10.1.7
@angular-devkit/schematics      11.0.7
@angular/cdk                    9.2.4
@schematics/angular             11.0.7
@schematics/update              0.1101.1
ng-packagr                      10.1.2
rxjs                            6.6.3
typescript                      4.1.3

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions