boatcoder boatcoder - 1 year ago 175
Javascript Question

Code coverage "Unknown" using jest 15.1.1

When I try to include all the project source code to get a more reasonable code coverage figure, I end up with

File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
All files | Unknown | Unknown | Unknown | Unknown | |

My config contains the following:

"collectCoverageFrom": [

I've also tried it without the trailing
, with
and with just a trailing
all to no avail.

Based on the
option, the path expands to the paths I want to collect coverage information from ( isn't the problem)

So what is the magic to getting more accurate coverage information?

The best docs I've been able to find come from this Github PR:

I ended up doing:

"collectCoverageFrom": [

which only worked because this is part of the default config

"testPathIgnorePatterns": [

It does add a huge amount of time to the test run though.

Answer Source

Look at your link very carefully:

collectCoverageFrom: { description: wrap( 'relative to <rootDir> glob pattern matching the files that coverage ' + 'info needs to be collected from.' ...

You can't use <rootDir>. Try:

collectCoverageFrom: [ "**/app_modules/**", "**/src/**" ],

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download