codecov is a great tool for adding coverage reports to your GitHub project, even viewing them inline on GitHub with a browser extension.
Assuming your npm test
does not run nyc
and you have the npx
executable (npm v5.2+), have your CI runner execute the following:
npx nyc --reporter=lcov npm test && npx codecov
npx
- Travis CI example using npm scripts npm install codecov nyc --save-dev
mocha
with your test runner): {
"scripts": {
"test": "nyc --reporter=lcov mocha",
"coverage": "codecov"
}
}
For private repos, add the environment variable CODECOV_TOKEN
to Travis CI.
add the following to your .travis.yml
:
after_success: npm run coverage