Skip to content

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

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

Merged
merged 1 commit into from
Feb 23, 2017

Conversation

filipesilva
Copy link
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

@@ -21,13 +22,25 @@ export function getTestConfig(testConfig: WebpackTestOptions) {
const extraRules: any[] = [];

if (testConfig.codeCoverage) {
const codeCoverageConfig = CliConfig.fromProject().config.test.codeCoverage;
Copy link
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

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
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

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
Copy link

takato1314 commented Sep 13, 2018

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

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