Skip to content

docs: Update code coverage story. #10498

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
Apr 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions docs/documentation/stories/code-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ To generate a coverage report run the following command in the root of your proj
ng test --watch=false --code-coverage
```

Once the tests complete a new `/coverage` folder will appear in the project. In your Finder or Windows Explorer open the `index.html` file. You should see a report with your source code and code coverage values.
Once the tests complete a new `/coverage` folder will appear in the project. In your Finder or Windows Explorer open the `index.html` file. You should see a report with your source code and code coverage values.

Using the code coverage percentages we can estimate how much of our code is tested. It is up to your team to determine how much code should be unit tested.
Using the code coverage percentages we can estimate how much of our code is tested. It is up to your team to determine how much code should be unit tested.

## Code Coverage Enforcement

Expand All @@ -27,6 +27,19 @@ coverageIstanbulReporter: {
functions: 80
}
}
```
```

The `thresholds` property will enforce a minimum of 80% code coverage when the unit tests are run in the project.

Another option to simplify the usage of code coverage, instead of passing it via the command line every time. Is to set the value within the configuration file `angular.json`.

```json
...
"test": {
"options": {
"codeCoverage": true
}
}
```

The `thresholds` property will enforce a minimum of 80% code coverage when the unit tests are run in the project.
This will produce code coverage results whenever tests are run for the project.