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
- add the codecov and nyc dependencies:
npm install codecov nyc --save-dev
- update the scripts in your package.json to include these lines (replace
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