diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/nyc/README.md | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/nyc/README.md')
-rw-r--r-- | node_modules/nyc/README.md | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/node_modules/nyc/README.md b/node_modules/nyc/README.md index 08160b587..f1c5e0a10 100644 --- a/node_modules/nyc/README.md +++ b/node_modules/nyc/README.md @@ -25,7 +25,7 @@ npm i nyc --save-dev ```json { - "script": { + "scripts": { "test": "nyc mocha" } } @@ -93,7 +93,7 @@ project uses the babel tool chain: ```json { "babel": { - "presets": ["es2015"], + "presets": ["env"], "env": { "test": { "plugins": ["istanbul"] @@ -154,7 +154,7 @@ nyc can fail tests if coverage falls below a threshold. After running your tests with nyc, simply run: ```shell -nyc --check-coverage --lines 95 --functions 95 --branches 95 +nyc check-coverage --lines 95 --functions 95 --branches 95 ``` nyc also accepts a `--check-coverage` shorthand, which can be used to @@ -169,7 +169,7 @@ The above check fails if coverage falls below 100%. To check thresholds on a per-file basis run: ```shell -nyc --check-coverage --lines 95 --per-file +nyc check-coverage --lines 95 --per-file ``` ## Running reports @@ -192,6 +192,13 @@ nyc report --reporter=lcov You can find examples of the output for various reporters [here](https://istanbul.js.org/docs/advanced/alternative-reporters). +You also have the choice of using a [custom reporter](https://github.com/pedrocarrico/istanbul-reporter-aws-cloudwatch-metrics). +Install custom reporters as a development dependency and you can use the `--reporter` flag to load and view them: + +```bash +nyc report --reporter=<custom-reporter-name> +``` + ## Excluding files You can tell nyc to exclude specific files and directories by adding @@ -216,7 +223,7 @@ and anything in the `build` directory: > Note: Since version 9.0 files under `node_modules/` are excluded by default. add the exclude rule `!**/node_modules/` to stop this. -> Note: exclude defaults to `['test', 'test{,-*}.js', '**/*.test.js', '**/__tests__/**', '**/node_modules/**']`, +> Note: exclude defaults to `['coverage/**', 'test/**', 'test{,-*}.js', '**/*.test.js', '**/__tests__/**', '**/node_modules/**']`, which would exclude `test`/`__tests__` directories as well as `test.js`, `*.test.js`, and `test-*.js` files. Specifying your own exclude property overrides these defaults. @@ -233,6 +240,8 @@ an `include` key with a list of globs to specify specific files that should be c } ``` +> `nyc` uses micromatch for glob expansions, you can read its documentation [here](https://www.npmjs.com/package/micromatch). + > Note: include defaults to `['**']` > ### Use the `--all` flag to include files that have not been required in your tests. @@ -272,6 +281,7 @@ Any configuration options that can be set via the command line can also be speci "exclude": [ "src/**/*.spec.js" ], + "ignore-class-method": "methodToIgnore", "reporter": [ "lcov", "text-summary" @@ -284,6 +294,7 @@ Any configuration options that can be set via the command line can also be speci ], "cache": true, "all": true, + "temp-directory": "./alternative-tmp", "report-dir": "./alternative" } } @@ -344,6 +355,19 @@ hints: * `/* istanbul ignore file */`: ignore an entire source-file (this should be placed at the top of the file). +## Ignoring Methods + +There may be some methods that you want to universally ignore out of your classes +rather than having to ignore every instance of that method: + +```json +{ + "nyc": { + "ignore-class-method": "render" + } +} +``` + ## Integrating with coveralls [coveralls.io](https://coveralls.io) is a great tool for adding @@ -360,7 +384,7 @@ integrated with coveralls and travis-ci.org: ```json { - "script": { + "scripts": { "test": "nyc mocha", "coverage": "nyc report --reporter=text-lcov | coveralls" } @@ -398,7 +422,7 @@ Here's how to get `nyc` integrated with codecov and travis-ci.org: ```json { - "script": { + "scripts": { "test": "nyc tap ./test/*.js", "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov" } |