codacy-coverage

Code Coverage reporter for Codacy.com
codacy coverage code coverage codacy.com


Summary

Project Name codacy-coverage Project Url https://github.com/codacy/node-codacy-coverage
InceptionYear 2015-02-03 11:30:12 更新时间 2019-01-03 02:09:58
IssueManagement https://github.com/codacy/node-codacy-coverage/issues Licenses MIT
仓库地址 git://github.com/codacy/node-codacy-coverage.git 用户数 3
Node Engine >= 8.12.0 文件大小 18.5 KB
install lint-style lint-dependencies test test-all

项目介绍

# Node Codacy Coverage Credits to [David](https://github.com/DavidTPate) for creating this! [Codacy](https://codacy.com/) support for Node.js. Get coverage reporting and code analysis for Node.js from Codacy. [![Codacy](https://api.codacy.com/project/badge/grade/3c7f5de6ce734762981d3e689de7b941)](https://www.codacy.com/app/codacy/node-codacy-coverage) [![Codacy](https://api.codacy.com/project/badge/coverage/3c7f5de6ce734762981d3e689de7b941)](https://www.codacy.com/app/codacy/node-codacy-coverage) [![Build Status](https://circleci.com/gh/codacy/node-codacy-coverage.png?style=shield&circle-token=:circle-token)](https://circleci.com/gh/codacy/node-codacy-coverage) [![npm](https://img.shields.io/npm/v/codacy-coverage.svg)](https://www.npmjs.com/package/codacy-coverage) [![npm](https://img.shields.io/npm/dm/codacy-coverage.svg)](https://www.npmjs.com/package/codacy-coverage) [![David](https://img.shields.io/david/codacy/node-codacy-coverage.svg)](https://david-dm.org/codacy/node-codacy-coverage) [![David](https://img.shields.io/david/dev/codacy/node-codacy-coverage.svg)](https://david-dm.org/codacy/node-codacy-coverage) [![David](https://img.shields.io/david/peer/codacy/node-codacy-coverage.svg)](https://david-dm.org/codacy/node-codacy-coverage) ## Installation Add the latest version of `codacy-coverage` to your package.json: ```sh npm install codacy-coverage --save ``` If you're using mocha, add `mocha-lcov-reporter` to your package.json: ```sh npm install mocha-lcov-reporter --save ``` ## Enterprise To send coverage in the enterprise version you should specify your Codacy installation URL with the option `-e`: ```sh codacy-coverage -e :16006 ``` ## Usage This cli can take standard input from any tool that emits the lcov data format (including [mocha](http://mochajs.org)'s [LCov reporter](https://npmjs.org/package/mocha-lcov-reporter)) and send it to Codacy to report your code coverage there. Once your app is instrumented for coverage, and building, you need to pipe the lcov output to `codacy-coverage`. ### Identifying the project You'll need to provide the secret Project API token from `Codacy Project > Settings > Integrations > Project API` via: * (Recommended) Environment variable: CODACY_PROJECT_TOKEN * CLI parameter variable: `--token` > Note: You should keep your any API token well **protected**, as it grants owner permissions to your projects. ### Test Coverage #### [Mocha](http://mochajs.org) + [Blanket.js](https://github.com/alex-seville/blanket) * Install [blanket.js](http://blanketjs.org/) * Configure blanket according to [docs](https://github.com/alex-seville/blanket/blob/master/docs/getting_started_node.md). * Add test with coverage step to your package.json: ```json "scripts": { "test-with-coverage": "NODE_ENV=test YOURPACKAGE_COVERAGE=1 mocha --require blanket --reporter mocha-lcov-reporter | codacy-coverage" } ``` * Run your tests with: ```sh npm run test-with-coverage ``` #### [Mocha](http://mochajs.org) + [JSCoverage](https://github.com/fishbar/jscoverage) Instrumenting your app for coverage is probably harder than it needs to be (read [here](http://www.seejohncode.com/2012/03/13/setting-up-mocha-jscoverage/)), but that's also a necessary step. * Add test with coverage step to your package.json: ```json "scripts": { "test-with-coverage": "YOURPACKAGE_COVERAGE=1 mocha test -R mocha-lcov-reporter | codacy-coverage" } ``` * Run your tests with: ```sh npm run test-with-coverage ``` #### [Istanbul](https://github.com/gotwarlost/istanbul) ##### With Mocha * Add test with coverage step to your package.json: ```json "scripts": { "test-with-coverage": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | codacy-coverage && rm -rf ./coverage" } ``` * Run your tests with: ```sh npm run test-with-coverage ``` ##### With Jasmine * Add test with coverage step to your package.json: ```json "scripts": { "test-with-coverage": "istanbul cover jasmine-node --captureExceptions spec/ && cat ./coverage/lcov.info | codacy-coverage && rm -rf ./coverage" } ``` * Run your tests with: ```sh npm run test-with-coverage ``` #### [Poncho](https://github.com/deepsweet/poncho) Client-side JS code coverage using [PhantomJS](https://github.com/ariya/phantomjs), [Mocha](http://mochajs.org) and [Blanket](https://github.com/alex-seville/blanket): * [Configure](http://mochajs.org#browser-support) Mocha for browser * [Mark](https://github.com/deepsweet/poncho#usage) target script(s) with `data-cover` html-attribute * Add test with coverage step to your package.json: ```json "scripts": { "test-with-coverage": "poncho -R lcov test/test.html | codacy-coverage" } ``` * Run your tests with: ```sh npm run test-with-coverage ``` #### [Jest](https://facebook.github.io/jest/) * Add test with coverage step to your package.json: Note: [jest might return exit code 1](https://github.com/facebook/jest/issues/3520) if you defined a coverage threshold and the threshold is not met ```json "scripts": { "test-with-coverage": "jest --coverage && cat ./coverage/lcov.info | codacy-coverage" } ``` * Run your tests with: ```sh npm run test-with-coverage ``` ## Extras ### Account Token As an alternative to the Project API token you can also send coverage using your account/api token by following steps: * Add test with coverage step to your package.json: ```json "scripts": { "test-with-coverage": "cat ./coverage/lcov.info | codacy-coverage --accountToken --username --projectName " } ``` * Run your tests with: ```sh npm run test-with-coverage ``` You'll need to provide the secret Account API token from [Codacy Account](https://app.codacy.com/account/apiTokens)` > API Tokens` via: * (Recommended) Environment variable: CODACY_ACCOUNT_TOKEN * CLI parameter variable: `--accountToken` ### Force custom language (e.g. Typescript, Coffeescript, C, ...) * Pass an extra parameter to the codacy-coverage reporter `--language typescript` or `--language coffeescript`. * If you have multiple languages you need to invoke the reporter for each of them. ### Run in Windows If you are running coverage in a windows machine without Unix tools, you need to change the command to `codacy-coverage < ./test/unit/coverage/lcov.info`. ## Troubleshooting ### Path Problems The paths in your coverage file should be relative, if you are having problems with absolute paths, you can run our plugin with `-p .` to strip the current path from the paths in your coverage file: ```json "scripts": { "test-with-coverage": "cat ./coverage/lcov.info | codacy-coverage -p ." } ``` ### Enterprise Coverage To send coverage in the **enterprise** version you should specify your Codacy installation URL followed by the port 16006 using the -e option, example: ```json "scripts": { "test-with-coverage": "cat ./coverage/lcov.info | codacy-coverage -e :16006" } ``` ## Options ```bash Options: -V, --version output the version number -f, --format [value] Coverage input format -t, --token [value] Codacy Project API Token -a, --accountToken [value] Codacy Account Token -u, --username [value] Codacy Username/Organization -n, --projectName [value] Codacy Project Name -c, --commit [value] Commit SHA hash -l, --language [value Project Language -e, --endpoint [value] Codacy API Endpoint -p, --prefix [value] Project path prefix -v, --verbose Display verbose output -d, --debug Display debug output -h, --help output usage information ``` ## License [MIT](LICENSE) ## What is Codacy [Codacy](https://www.codacy.com/) is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews. ### Among Codacy’s features * Identify new Static Analysis issues * Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories) * Auto-comments on Commits and Pull Requests * Integrations with Slack, HipChat, Jira, YouTrack * Track issues Code Style, Security, Error Proneness, Performance, Unused Code and other categories Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity. Codacy supports PHP, Python, Ruby, Java, JavaScript, and Scala, among others. ### Free for Open Source Codacy is free for Open Source projects.

Dependencys

GroupId ArtifactID Version 引用量
Petka Antonov bluebird 3.7.2 25090
TJ Holowaychuk commander 5.1.0 42562
Vokal jacoco-parse 2.0.1 4
hueniverse joi 14.3.1 3569
Dav Glass lcov-parse 1.0.0 57
John-David Dalton lodash 4.17.15 87062
Gregg Caines log-driver 1.2.7 28
Mikeal Rogers request 2.88.2 47766
Nicolai Kamenzky request-promise 4.2.5 6455

开发依赖

GroupId ArtifactID Version 引用量
Jake Luer chai 4.2.0 90846
Domenic Denicola chai-as-promised 7.1.1 8265
Joshua Perry dirty-chai 2.0.1 975
Nicholas C. Zakas eslint 7.1.0 210686
Krishnan Anantheswaran istanbul 0.4.5 223
Daniel St. Jules jsinspect 0.12.7 172
Pedro Teixeira nock 12.0.3 8256