Skip to content

feat(@angular/cli): allow code coverage excludes - #4966

Merged
filipesilva merged 1 commit into
angular:masterfrom
filipesilva:cc-exclude
Feb 23, 2017
Merged

filipesilva merged 1 commit into
angular:masterfrom
filipesilva:cc-exclude

Conversation

@filipesilva

Copy link
Copy Markdown
Contributor

A new CLI config entry under test allows you to list exclude globs for code coverage:

  "test": {
    "codeCoverage": {
      "exclude": [
        "src/polyfills.ts",
        "**/test.ts"
      ]
    },
    "karma": {
      "config": "./karma.conf.js"
    }
  },

/cc @delasteve

const extraRules: any[] = [];

if (testConfig.codeCoverage) {
const codeCoverageConfig = CliConfig.fromProject().config.test.codeCoverage;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fromProject() can return null, and test and codeCoverage might be missing from the config. Use get() to allow for defaults.

A new CLI config entry under `test` allows you to list exclude globs for code coverage:

```
  "test": {
    "codeCoverage": {
      "exclude": [
        "src/polyfills.ts",
        "**/test.ts"
      ]
    },
    "karma": {
      "config": "./karma.conf.js"
    }
  },
```
@filipesilva
filipesilva merged commit b6893d0 into angular:master Feb 23, 2017
@filipesilva
filipesilva deleted the cc-exclude branch February 23, 2017 20:42
asnowwolf pushed a commit to asnowwolf/angular-cli that referenced this pull request Apr 12, 2017
A new CLI config entry under `test` allows you to list exclude globs for code coverage:

```
  "test": {
    "codeCoverage": {
      "exclude": [
        "src/polyfills.ts",
        "**/test.ts"
      ]
    },
    "karma": {
      "config": "./karma.conf.js"
    }
  },
```
@pete-otaqui

Copy link
Copy Markdown

Am I correct in thinking that this is no longer possible with the latest version 6.0.0 of angular-cli?

I've tried adding a codeCoverage block to angular.json, and get an error about that being invalid according to the schema.

Is something like this available with 6.0.0, and if so how should it be used?

@filipesilva

Copy link
Copy Markdown
Contributor Author

@pete-otaqui this should work on 6.0:

"test": {
  "builder": "@angular-devkit/build-angular:karma",
  "options": {
    "main": "src/test.ts",
    // ...
    "codeCoverageExclude": [
      "src/polyfills.ts",
      "**/test.ts"
    ]
  }
},

@pete-otaqui

Copy link
Copy Markdown

Thanks for that - I actually managed to work that out by searching the repo for "codeCoverageExclude", working out where from the angular.json schema that key was allowed and went form there.

Thanks again for the example

@takato1314

takato1314 commented Sep 13, 2018 •

Copy link
Copy Markdown

It would be nice too if the documentation can be updated to align with the changes that @filipesilva mentioned.

Currently it only mentioned that it expects the name of the test entry-point file.

@angular-automatic-lock-bot

Copy link
Copy Markdown

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 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants