Istanbul: Error running `istanbul check-coverage`

Created on 9 Dec 2015  路  10Comments  路  Source: gotwarlost/istanbul

/project-path/node_modules/istanbul/lib/object-utils.js:247
            for (i = 0; i < retArray.length; i += 1) {
                                    ^

TypeError: Cannot read property 'length' of undefined
    at /project-path/node_modules/istanbul/lib/object-utils.js:247:37
    at Array.forEach (native)
    at Object.mergeFileCoverage (/project-path/node_modules/istanbul/lib/object-utils.js:244:31)
    at /project-path/node_modules/istanbul/lib/collector.js:71:44
    at Array.forEach (native)
    at Object.Collector.add (/project-path/node_modules/istanbul/lib/collector.js:68:31)
    at /project-path/node_modules/istanbul/lib/command/check-coverage.js:125:27
    at Array.forEach (native)
    at /project-path/node_modules/istanbul/lib/command/check-coverage.js:123:19
    at /project-path/node_modules/istanbul/lib/util/file-matcher.js:39:20

Using karma, browserify-istanbul and istanbul (v0.4.0) to check the coverage files. Has anyone seen this before?

Most helpful comment

Was having the same issue but deleting my coverage folder fixed it.

All 10 comments

My issue was resolved by removing my node_modules folder and reinstalling everything. I've got no idea why.

Still seeing this issue using Jest Client 0.7.1 with Istanbul 0.3.22 along with RN 22

I am also getting similar issue (using karma-cli v3.8.9)

 PROJECT_PATH\node_modules\istanbul\lib\object-utils.js:247
             for (i = 0; i < retArray.length; i += 1) {
                                     ^

 TypeError: Cannot read property 'length' of undefined
     at PROJECT_PATH\node_modules\istanbul\lib\object-utils.js:247:37
     at Array.forEach (native)
     at Object.mergeFileCoverage (PROJECT_PATH\node_modules\istanbul\lib\object-utils.js:244:31)
     at PROJECT_PATH\node_modules\istanbul\lib\collector.js:71:44
     at Array.forEach (native)
     at Object.Collector.add (PROJECT_PATH\node_modules\istanbul\lib\collector.js:68:31)
     at PROJECT_PATH\node_modules\istanbul\lib\command\check-coverage.js:125:27
     at Array.forEach (native)
     at PROJECT_PATH\node_modules\istanbul\lib\command\check-coverage.js:123:19
     at PROJECT_PATH\node_modules\istanbul\lib\util\file-matcher.js:39:20
     at Object.next (PROJECT_PATH\node_modules\fileset\lib\fileset.js:43:14)
     at emitOne (events.js:96:13)
     at Fileset.emit (events.js:188:7)
     at Fileset.Glob._finish (PROJECT_PATH\node_modules\fileset\node_modules\glob\glob.js:172:8)
     at done (PROJECT_PATH\node_modules\fileset\node_modules\glob\glob.js:159:12)
     at Fileset.Glob._processGlobStar2 (PROJECT_PATH\node_modules\fileset\node_modules\glob\glob.js:601:12)

 Process finished with exit code 1

Resolution: To resolve the issue I had to do gulp clean, probably there was some artifact leftover by karma that was causing the issue. Just removing the node_modules did not work for me.

I have removed and reinstalled node_modules a dozen times and I still get this issue.

Have you tried doing a fresh clone of the project? Do you have any globally installed node_modules which may be screwing with any versions of modules? Have you removed the coverage files?

I'm using Istanbul 0.4.4 and Mocha 2.5.3 and I keep hitting this issue, tried reinstalling all of the node_modules and deleting and re-cloning the project and I'm still getting this error.

Was having the same issue but deleting my coverage folder fixed it.

I removed the --all flag from NYC and it fixed it.

UPDATES MAR 15 16:41

I had reporter.addAll(['json', 'text', 'lcov', 'cobertura']);
I just needed to remove lcov and it works just fine.


@reggi how do you remove the --all ?

I'm facing the same issue:

<project-path>/node_modules/istanbul/lib/object-utils.js:247
            for (i = 0; i < retArray.length; i += 1) {
                                    ^

TypeError: Cannot read property 'length' of undefined
    at <project-path>/node_modules/istanbul/lib/object-utils.js:247:37

I'm using jest and the error happens when I have this:

  "collectCoverageFrom": [
    "!**/node_modules/**",
    "<rootDir>/src/client/**/*.js",
    "<rootDir>/src/server/**/*.js",
    "<rootDir>/src/shared/**/*.js"
  ],

When I do it without collectCoverageFrom, it works just fine but it only collects from the files that is being tested, which would provide incorrect coverage from.

Removing the coverage folder did the trick for me. -.-

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asciidisco picture asciidisco  路  47Comments

graemej picture graemej  路  22Comments

amoufaddel picture amoufaddel  路  28Comments

Raynos picture Raynos  路  27Comments

jasonpincin picture jasonpincin  路  22Comments