jeffrifwald / babel-istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
144 stars 23 forks source link

TypeError in lib/object-utils.js #52

Closed silkentrance closed 8 years ago

silkentrance commented 8 years ago

I have a project that will generate a TypeError in lib/object-utils.js when checking the coverage status.

See https://github.com/coldrye-es/ypo-parser. In order to build, first clone and then run npm install esmake in the project's folder.

Of course you need to have a linux based system to get this up and running. If so and you don't mind the global dependencies installed via sudo, just run make deps deps-global cover check-cover and see it failing. Or just use a VM for this.

Here is the stack trace

checking coverage...
--------------------------
[ '0', '1', '2', '3', '4', '5' ]
--------------------------
/usr/lib/node_modules/babel-istanbul/lib/object-utils.js:241
        Object.keys(second.s).forEach(function (k) {
               ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (native)
    at Object.mergeFileCoverage (/usr/lib/node_modules/babel-istanbul/lib/object-utils.js:241:16)
    at /usr/lib/node_modules/babel-istanbul/lib/collector.js:71:44
    at Array.forEach (native)
    at Object.Collector.add (/usr/lib/node_modules/babel-istanbul/lib/collector.js:68:31)
    at /usr/lib/node_modules/babel-istanbul/lib/command/check-coverage.js:125:27
    at Array.forEach (native)
    at /usr/lib/node_modules/babel-istanbul/lib/command/check-coverage.js:123:19
    at /usr/lib/node_modules/babel-istanbul/lib/util/file-matcher.js:39:20
    at Object.next (/usr/lib/node_modules/babel-istanbul/node_modules/fileset/lib/fileset.js:43:14)
node_modules/esmake/Makefile.software.in:79: recipe for target 'check-cover' failed

As you can see above between the ------, the actual keys of second are different from the ones expected by object-utils, that is, neither second.s nor second.f nor second.b are defined.

Here is my .istanbul.yml config

instrumentation:
    extensions:
        - .es
    excludes: ["build/test/*.js"]
reporting:
    dir: ./build/cover
    reports:
        - lcov
        - html
    print: summary
    watermarks:
        statements: [40, 100]
        lines: [40, 100]
        functions: [40, 100]
        branches: [40, 100]
    report-config:
        clover: {file: clover.xml}
        cobertura: {file: cobertura-coverage.xml}
        json: {file: coverage-final.json}
        json-summary: {file: coverage-summary.json}
        lcovonly: {file: lcov.info}
        teamcity: {file: null}
        text: {file: null, maxCols: 0}
        text-lcov: {file: lcov.info}
        text-summary: {file: null}
check:
    global:
        branches: 50
        functions: 50
        lines: 50
        statements: 50
silkentrance commented 8 years ago

SIGH forget it :grin:, after having updated my global dependencies everythings works like a charm again.

And it has something to do with my build process...argh