In order to get this up and running you'll need a few things:
A Coveralls account. To set this up, go over to Coveralls. Log-in with your Github account.
With all that set-up you should be able to get code coverage results rendering in your GitHub within about 10 minutes, so let's get cracking.
How To Set-up Coveralls
istanbul. Istanbul will create a nice report for you to able to view your code coverage results. Coveralls will render that report within GitHub.
After that run this command from a terminal:
With those packages installed within your projects
packages.json, you need to create a new script to generate your code coverage report. You can do this, using the following snippet:
Next, if you are using Travis then you should have a
travis.yml file. Update this file to call the new script like this:
The final config is to add a
To send coverage data to Coveralls, log into the Coveralls portal and enable your project, by clicking on the 'Add Repos', finding your project and clicking the on button:
Within the project settings, navigate to the bottom and you should see a 'badge your repo section':
Click on the drop-down that says embed and copy the code from within the markdown section. Add this snippet within your projects
readme.md file, commit and push it. This should trigger an automatic build in Travis. On your Github page, you should now see a badge with your coveralls report. You should now see a report being generated in coveralls and your badge displays your code coverage.
Dealing With Issues
First, if you have an issue try running the cover script locally, you can do this with the
npm cover command. If that works, you have probably misconfigured something in coveralls. If you think you have set everything up, you can take a look at this project to help you figure it out, HTTP Status Lookup. Happy Coding 🤘