|
1 | 1 | # nyc
|
2 | 2 |
|
3 |
| -[](https://travis-ci.org/bcoe/nyc) |
4 |
| -[](https://coveralls.io/r/bcoe/nyc?branch=) |
| 3 | +[](https://travis-ci.org/istanbuljs/nyc) |
| 4 | +[](https://coveralls.io/r/istanbuljs/nyc?branch=master) |
5 | 5 | [](https://www.npmjs.com/package/nyc)
|
6 |
| -[](https://ci.appveyor.com/project/bcoe/nyc) |
| 6 | +[](https://ci.appveyor.com/project/istanbuljs/nyc) |
7 | 7 | [](https://github.com/conventional-changelog/standard-version)
|
8 | 8 |
|
9 |
| -a code coverage tool built on [istanbul](https://www.npmjs.com/package/istanbul) |
10 |
| -that works for applications that spawn subprocesses. |
| 9 | +Istanbul's high-tech command line interface, with support for: |
| 10 | + |
| 11 | +* applications that spawn subprocesses. |
| 12 | +* ES2015 transforms, via [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul), or source-maps. |
11 | 13 |
|
12 | 14 | ## Instrumenting Your Code
|
13 | 15 |
|
@@ -60,26 +62,27 @@ of the pre-transpiled code. You'll have to configure your custom require hook
|
60 | 62 | to inline the source map in the transpiled code. For Babel that means setting
|
61 | 63 | the `sourceMaps` option to `inline`.
|
62 | 64 |
|
63 |
| -## Use babel-plugin__coverage__ for Better ES6/ES7 Support |
| 65 | +## Use with babel-plugin-istanbul for Better ES6/ES7 Support |
64 | 66 |
|
65 |
| -[`babel-plugin-__coverage__`](https://github.com/dtinth/babel-plugin-__coverage__) can be used to enable better first-class ES6 support. |
| 67 | +[`babel-plugin-istanbul`](https://github.com/istanbuljs/babel-plugin-istanbul) can be used to enable better first-class ES6 support. |
66 | 68 |
|
67 |
| -1. enable the `__coverage__` plugin: |
| 69 | +1. enable the `babel-plugin-istanbul` plugin: |
68 | 70 |
|
69 | 71 | ```json
|
70 | 72 | {
|
71 | 73 | "babel": {
|
72 | 74 | "presets": ["es2015"],
|
73 | 75 | "env": {
|
74 | 76 | "test": {
|
75 |
| - "plugins": ["__coverage__"] |
| 77 | + "plugins": ["istanbul"] |
76 | 78 | }
|
77 | 79 | }
|
78 | 80 | }
|
79 | 81 | }
|
80 | 82 | ```
|
81 | 83 |
|
82 |
| - Note: With this configuration, the `__coverage__` will only be active when `NODE_ENV` or `BABEL_ENV` is `test`. |
| 84 | + Note: With this configuration, the Istanbul instrumentation will only be active when `NODE_ENV` or `BABEL_ENV` is `test`. |
| 85 | + |
83 | 86 | We recommend using the [`cross-env`](https://npmjs.com/package/cross-env) package to set these environment variables
|
84 | 87 | in your `package.json` scripts in a way that works cross-platform.
|
85 | 88 |
|
@@ -125,15 +128,13 @@ nyc --extension .jsx --extension .es6 npm test
|
125 | 128 |
|
126 | 129 | ## Checking Coverage
|
127 | 130 |
|
128 |
| -nyc exposes istanbul's check-coverage tool. After running your tests with nyc, |
129 |
| -simply run: |
| 131 | +nyc can fail tests if coverage falls below a threshold. |
| 132 | +After running your tests with nyc, simply run: |
130 | 133 |
|
131 | 134 | ```shell
|
132 | 135 | nyc check-coverage --lines 95 --functions 95 --branches 95
|
133 | 136 | ```
|
134 | 137 |
|
135 |
| -This feature makes it easy to fail your tests if coverage drops below a given threshold. |
136 |
| - |
137 | 138 | nyc also accepts a `--check-coverage` shorthand, which can be used to
|
138 | 139 | both run tests and check that coverage falls within the threshold provided:
|
139 | 140 |
|
@@ -239,17 +240,6 @@ can also be specified in the `nyc` stanza of your package.json:
|
239 | 240 | }
|
240 | 241 | ```
|
241 | 242 |
|
242 |
| -## Configuring Istanbul |
243 |
| - |
244 |
| -Behind the scenes nyc uses [istanbul](https://www.npmjs.com/package/istanbul). You |
245 |
| -can place a `.istanbul.yml` file in your project's root directory to pass config |
246 |
| -setings to istanbul's code instrumenter: |
247 |
| - |
248 |
| -```yml |
249 |
| -instrumentation: |
250 |
| - preserve-comments: true |
251 |
| -``` |
252 |
| -
|
253 | 243 | ## Integrating With Coveralls
|
254 | 244 |
|
255 | 245 | [coveralls.io](https://coveralls.io) is a great tool for adding
|
@@ -285,7 +275,6 @@ That's all there is to it!
|
285 | 275 |
|
286 | 276 | > Note: by default coveralls.io adds comments to pull-requests on GitHub, this can feel intrusive. To disable this, click on your repo on coveralls.io and uncheck `LEAVE COMMENTS?`.
|
287 | 277 |
|
288 |
| - |
289 | 278 | ## Integrating with codecov
|
290 | 279 |
|
291 | 280 | `nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov`
|
|
0 commit comments