Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
woteska opened this issue Nov 12, 2020 · 4 comments · Fixed by #19361
Closed

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

woteska opened this issue Nov 12, 2020 · 4 comments · Fixed by #19361

Comments

@woteska
Copy link

woteska commented Nov 12, 2020

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! [email protected] 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
  });
};
@alan-agius4
Copy link
Collaborator

For the moment you can workaround this by using

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

@woteska
Copy link
Author

woteska commented Nov 12, 2020

For the moment you can workaround this by using

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

Thanks for the answer. Can we estimate that when can we run tests with coverage-istanbul again?

clydin pushed a commit that referenced this issue Nov 12, 2020
… when it's not configured

This fixes an issue where previously `karma-coverage must be installed in order to run code coverage` error was shown incorrectly.

Closes: #19359
clydin pushed a commit that referenced this issue Nov 12, 2020
… when it's not configured

This fixes an issue where previously `karma-coverage must be installed in order to run code coverage` error was shown incorrectly.

Closes: #19359
(cherry picked from commit 88a3794)
@alan-agius4
Copy link
Collaborator

alan-agius4 commented Nov 12, 2020

You don’t provide coverage/coverage-reporter manually via the —reporters as this is done automatically when using the —code-coverage option.

The fix was just released.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants