How to make Istanbul generate coverage for all of my source code?

Seer picture Seer · Dec 22, 2014 · Viewed 13.4k times · Source

Currently Istanbul is only generating coverage for files that are used in my tests, which is okay, but seems to defeat the purpose of having coverage somewhat.

I have no Istanbul configuration, and am invoking it via npm test with the following script string:

$ istanbul cover _mocha -- -R dot --check-leaks --recursive test/

Is there a way to generate coverage for all of my source code?

Answer

Seer picture Seer · Dec 25, 2014

Found the answer, I think I'm partly lucky that the directory structure I have chosen allows me to use this option, but my test command is now:

$ istanbul --include-all-sources cover _mocha -- -R dot --recursive test/

The --include-all-sources is the important part.