Skip to content

Ignore files/folders from code coverage report #3356

Closed

Description

@k-schneider

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Windows 10

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

angular-cli: 1.0.0-beta.19-3
node: 5.10.1
os: win32 x64

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
N/A

The log given by the failure.

Normally this include a stack trace and some more information.
N/A

Mention any other details that might be useful.

Is there any way to exclude files/folders from test coverage (other than naming them .spec.ts)?
For example if I wanted to put some reusable bits of test code in src/app/common/testing/
* I wouldn't want files included in this directory to be reported on.

Thanks!


Thanks! We'll be in touch soon.

Activity

  1. added
    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
    featureLabel used to distinguish feature request from other issues
    on Dec 2, 2016
  2. dpmorrow commented on Jan 25, 2017

    @dpmorrow

    Just wanted to make sure you all know that upgrading your project to karma-remap-istanbul:^0.3.0 will allow you to use their exclude property.
    marcules/karma-remap-istanbul#26

  3. Wolfium commented on Jan 31, 2017

    @Wolfium

    I just tried installing karma-remap-istanbul:^0.3.0 and karma-remap-istanbul:^0.4.0 with no luck at all.
    Excluded path includiing '/data/' still in reports.

    karma.conf.js:
    remapIstanbulReporter: {
    remapOptions: {
    exclude: '/data/',
    },
    reports: {
    html: 'coverage',
    lcovonly: './coverage/coverage.lcov'
    }
    },

    Versions:
    angular-cli: 1.0.0-beta.24

    Thanks in advance for any ideas or help?

  4. dpmorrow commented on Jan 31, 2017

    @dpmorrow

    @Nestor forgive me but I just want to be sure that you:

    • forced npm to install the new version not just updated the config
    • you are able to exclude something else using the remapOption exclude
    • understand that it will be trying to exclude the string /data/ not the regex pattern which would require you to remove the quotes.

    Not totally sure myself how the string implementation works but if everything else checks maybe switch to regex?

    HTH

  5. Wolfium commented on Feb 1, 2017

    @Wolfium

    Hi, @dpmorrow, answers follow:

    • I confirm that both version where installed using npm install command, which indeed update the package config once successfully dependency installed, not the opposite.
    • I was able to exclude something once I understood and got a matching filter.
    • Not sure if it it was a question, but the problem is not the exclude or string implementation, the problem is the LCOV input data is not platform independent, which in my case using windows, it uses backslash as path separator in SF values.

    After some research look like istanbul generate the LCOV file depending on the platform which add a platfom dependen matching which a worked around using a regexp accepting slash and backslash as separator.

    Will need some time to fork istanbul repo and test it under windows locally.

  6. delasteve commented on Feb 23, 2017

    @delasteve
    Contributor

    When RC is released you will be able to configure the following section in the .angular-cli.json file:

    "test": {
      "codeCoverage": {
        "exclude": ["glob/to/ignore"]
      },
      ...
    }
  7. hansl commented on Feb 23, 2017

    @hansl
    Contributor

    Fixed in master by #4966

  8. gregbown commented on May 14, 2018

    @gregbown

    With the latest CLI 6+ add excluded files or paths to angular.json -> test -> options like so:

            "test": {
              "builder": "@angular-devkit/build-angular:karma",
              "options": {
                "main": "src/test.ts",
                "polyfills": "src/polyfills.ts",
                "tsConfig": "src/tsconfig.spec.json",
                "karmaConfig": "./karma.conf.js",
                "codeCoverageExclude": ["src/testing/**/*"],
    

    I should add, this addition was found by going through the schema

    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    
  9. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  10. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenteffort1: easy (hours)featureLabel used to distinguish feature request from other issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions