Skip to content

How to run test with teamcity and coverage-istanbul reporters only? (Angular 11) #19359

Closed
@woteska

Description

@woteska

I just updated the project to Angular 11. Our builds failed on

ng "test" "--watch=false" "--code-coverage" "--browsers=ChromeHeadless" "--reporters=teamcity,coverage-istanbul"

[14:32:50][JavaScript Unit Tests] 12 11 2020 14:32:50.669:INFO [karma-server]: Karma v5.1.1 server started at http://localhost:9876/
[14:32:50][JavaScript Unit Tests] 12 11 2020 14:32:50.670:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
[14:32:50][JavaScript Unit Tests] 12 11 2020 14:32:50.670:ERROR [karma-server]: Error: Found 1 load error
[14:32:50][JavaScript Unit Tests]     at Server.<anonymous> (C:\TeamCity\buildAgent\work\74e1703a2bfba134\xxx\Frontend\node_modules\karma\lib\server.js:189:27)
[14:32:50][JavaScript Unit Tests]     at Object.onceWrapper (events.js:299:28)
[14:32:50][JavaScript Unit Tests]     at Server.emit (events.js:215:7)
[14:32:50][JavaScript Unit Tests]     at emitListeningNT (net.js:1332:10)
[14:32:50][JavaScript Unit Tests]     at processTicksAndRejections (internal/process/task_queues.js:79:21)
[14:32:50][JavaScript Unit Tests] npm ERR! code ELIFECYCLE
[14:32:50][JavaScript Unit Tests] npm ERR! errno 1
[14:32:50][JavaScript Unit Tests] npm ERR! xxx@1.4.0 ng: `ng "test" "--watch=false" "--code-coverage" "--browsers=ChromeHeadless" "--reporters=teamcity,coverage-istanbul"`

It even doesn't work if I modify coverage-istanbul reporter to coverage.

ng "test" "--watch=false" "--code-coverage" "--browsers=ChromeHeadless" "--reporters=teamcity,coverage"
12 11 2020 16:01:31.036:ERROR [karma-server]: Server start failed on port 9876: Error: karma-coverage must be installed in order to run code coverage

But karma-coverage is installed via the latest CLI:

  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1100.0",
    "@angular/cli": "~11.0.0",
    "@angular/compiler-cli": "~11.0.0",
    "@types/jasmine": "~3.6.0",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.1.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "karma-teamcity-reporter": "^1.1.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.2"
  }

How can I run the tests with the new coverage and teamcity reporters only?

Project generated by the latest CLI (v11), it has the default karma configuration + teamcity reporter imported:

// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage'),
      require('@angular-devkit/build-angular/plugins/karma'),
      require('karma-teamcity-reporter')
    ],
    client: {
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageReporter: {
      dir: require('path').join(__dirname, './coverage/xxx'),
      subdir: '.',
      reporters: [
        { type: 'html' },
        { type: 'text-summary' }
      ],
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false,
    restartOnFileChange: true
  });
};

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions