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

Test-coverage says that coverage is not 100%, but it truly is! #5871

Closed
askarby opened this issue Apr 7, 2017 · 16 comments
Closed

Test-coverage says that coverage is not 100%, but it truly is! #5871

askarby opened this issue Apr 7, 2017 · 16 comments
Labels
effort1: easy (hours) needs: investigation Requires some digging to determine if action is needed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity1: confusing

Comments

@askarby
Copy link

askarby commented Apr 7, 2017

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.0.0
node: 6.9.5
os: darwin x64
@angular/animations: 4.0.1
@angular/common: 4.0.1
@angular/compiler: 4.0.1
@angular/core: 4.0.1
@angular/forms: 4.0.1
@angular/http: 4.0.1
@angular/platform-browser: 4.0.1
@angular/platform-browser-dynamic: 4.0.1
@angular/platform-server: 4.0.1
@angular/router: 4.0.1
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.1

Repro steps.

Upgrade your 100% tested angular 2.4.8 app to 4.0.1, along with Angular CLI 1.0.0

The log given by the failure.

There's no actual failure (stacktrace thown), but the behaviour of the text-coverage is wrong. I'm hitting every line, statement, branch and function of the code, but coverage does not "cover" constructor signature.

Desired functionality.

The test coverage should be 100%, and was until I upgraded from Angular 2.4.8 (CLI 1.0.0 RC.0) to Angular 4.01 (CLI 1.0.0).

Before
before

After
after

Coverage error (example)
example

Mention any other details that might be useful.

My karma.conf.js file looks like:

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

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma'),
      require('karma-spec-reporter'),
      require('karma-appveyor-reporter')
    ],
    files: [
      {pattern: './src/test.ts', watched: false}
    ],
    preprocessors: {
      './src/test.ts': ['@angular/cli']
    },
    mime: {
      'text/x-typescript': ['ts', 'tsx']
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly', 'text' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: config.angularCli && config.angularCli.codeCoverage
      ? ['spec', 'coverage-istanbul', 'appveyor']
      : ['spec', 'appveyor'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

I'm unfortunately not permitted to share the code-base, since it's a closed source, propriatary product I'm working on. I can however provide you with various configuration files. So, do not refrain from asking for these.

@victornoel
Copy link

victornoel commented Apr 10, 2017

We have the same problem on this opensource project: https://gitlab.com/linagora/petals-cockpit (at commit 78c6928e4f78279a2a105fe357981a6cff88da21).

@chris-jones-pixitmedia
Copy link

Same issue here, certain constructor params are marked as 'branch not covered'. Same code / tests run against previous versions of the CLI report 100% coverage.

@marekszczepansky
Copy link

Unfortunately I have the same. Even 4 issues in one constructor :(

@jeffarese
Copy link

👍 having the same problem

@freeman29
Copy link

👍 encountered same issue

@filipesilva
Copy link
Contributor

At one point we switched the karma code-coverage plugin, that might be related.

@filipesilva filipesilva added effort1: easy (hours) needs: investigation Requires some digging to determine if action is needed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity1: confusing labels May 4, 2017
@elektroels
Copy link

Same problem

@kenisteward
Copy link

Same issue but I'm looking into the matter. Will start looking at what exactly the karma plugin is doing.

@dimitriy-k
Copy link

fix it please :)

@ryzy
Copy link

ryzy commented Jun 18, 2017

Because of that reason, I'm using newest ng, but replacing karma.conf with karma-remap-istanbul setup (like it was before we switched to code-coverage plugin).

It's not silver bullet, the issue is still present in setup with karma-remap-istanbul, but with less branches reported as not-tested.

@rg1220
Copy link

rg1220 commented Jul 2, 2017

+1 Having the same issue in several places:

screen shot 2017-07-02 at 8 55 13 am

screen shot 2017-07-02 at 8 54 40 am

screen shot 2017-07-02 at 8 56 24 am

@rg1220
Copy link

rg1220 commented Jul 2, 2017

Appears to be a duplicate of #5526

@askarby
Copy link
Author

askarby commented Jul 11, 2017

@rg1220

Well, not exactly... since we're not only experiencing it in constructors, but also in class parameters.

@aniruddhadas9
Copy link
Contributor

I am also unable to cover 100% code coverage due to this problem. Will wait until it will be pushed into later version.

currently using 1.1.0

  constructor(private elementRef: ElementRef, private tagApi: TagApi, private tagTypeApi: TagTypeApi,
              private businessObjectDefinitionTagApi: BusinessObjectDefinitionTagApi) {
  }
 

these two properties are not covered expect everything else is fine.
private tagApi: TagApi, private tagTypeApi: TagTypeApi,

@filipesilva
Copy link
Contributor

Going to close this one as duplicate of #5526, they are the same and the other one has a lot more info on the problem.

@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 Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort1: easy (hours) needs: investigation Requires some digging to determine if action is needed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity1: confusing
Projects
None yet
Development

No branches or pull requests