gotwarlost / 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
8.7k stars 786 forks source link

libReport.createReportSource is not a function #655

Closed JakeSidSmith closed 8 years ago

JakeSidSmith commented 8 years ago

Was running this exact setup a day or two ago & things were working fine. Today I'm getting an error from inside istanbul-api.

Example logs: https://travis-ci.org/JakeSidSmith/canvasimo/builds/140217808

When running the following npm script

istanbul cover node_modules/mocha/bin/_mocha -- --require tests/helpers/test-setup.js --bail --recursive tests

Have tried running node 4.3.1, 6.1.0 and 6.2.1.

With the following dependencies

  "devDependencies": {
    "chai": "=3.5.0",
    "istanbul": "=1.0.0-alpha.2",
    "jsdom": "=8.4.1",
    "mocha": "=2.4.5",
    "sinon": "=1.17.3",
    "sinon-chai": "=2.8.0"
  },

Error

/project/node_modules/istanbul/node_modules/istanbul-api/lib/reporter.js:80
        reportSource = libReport.createReportSource(coverageMap, opts);
                                 ^

TypeError: libReport.createReportSource is not a function
    at Object.Reporter.write (/project/node_modules/istanbul/node_modules/istanbul-api/lib/reporter.js:80:34)
    at exitFn (/project/node_modules/istanbul/node_modules/istanbul-api/lib/run-cover.js:127:18)
    at process.g (events.js:260:16)
    at emitOne (events.js:77:13)
    at process.emit (events.js:169:7)
    at process.exit (node.js:745:17)
    at done (/project/node_modules/mocha/bin/_mocha:416:32)
    at afterWrite (_stream_writable.js:346:3)
    at nextTickCallbackWithManyArgs (node.js:459:18)
    at process._tickCallback (node.js:357:17)
JakeSidSmith commented 8 years ago

Solution: Ok, after some playing around it seems that this is not an issue in 1.1.0-alpha.1.

I would suggest you pin your dependencies (at least the ones maintained by yourself) to exact versions to avoid this in the future.

Might be worth leaving this issue open for anyone else experiencing it.

Seraf commented 8 years ago

Hello, exactly the same thing here.

@JakeSidSmith, I don't understand, what is the issue ? Should we pin to a previous version ? I tried to upgrade to 1.1.0-alpha.1 but same problem.

Any idea ?

Thanks

JakeSidSmith commented 8 years ago

Clear your node_modules and reinstall. Should work fine. :)

JakeSidSmith commented 8 years ago

@gotwarlost Could deprecate the version that is now not working.

Seraf commented 8 years ago

Oh, thanks for the help @JakeSidSmith, didn't thought about removing my node_modules directory. Doing a fresh install using the last alpha solved my problem.

gotwarlost commented 8 years ago

I'm hard-pressed to figure out what is going on. That function and the call to it were both taken out in Nov 2015.

https://github.com/istanbuljs/istanbul-lib-report/commit/72fd1d4dca8170a2027c492cc3cccc7edcb6e80e https://github.com/istanbuljs/istanbul-api/commit/49f3c76673b0a0e8c82fafe8719aa3687b9d3228

I can understand an incremental upgrade to your dependencies somehow causing this but I cannot understand how a fresh install in travis can cause this problem.

gotwarlost commented 8 years ago

The first version of the API library has a misspelled alpha string '1.0.0-aplha.1 and I think what's going on is that this string is being preferred to alpha because of lexicographic sorting? If so, why didn't this problem show up before?

gotwarlost commented 8 years ago

What's more builds 336 and 338 have the same exact versions of istanbul libs but 336 worked and 338 failed.

https://travis-ci.org/JakeSidSmith/canvasimo/builds/140217658 https://travis-ci.org/JakeSidSmith/canvasimo/builds/140217808

gotwarlost commented 8 years ago

OK, I fixed this by publishing a [misspelt] 1.0.0-aplha.10 version from the [correct] 1.0.0-alpha.10 tag so that it hides the bad aplha version. This seems to fix the issue.

@bcoe - interesting npm-related issue which may be correct behavior on npm's part but has the property that the unexpected behavior doesn't show up until a new minor version is published. I'm not sure I understood what's going on fully. Anyway, I put in a band-aid for now.

JakeSidSmith commented 8 years ago

@gotwarlost The versions defined in the package.json allow the dependencies in question to use whatever the latest minor version is.

"istanbul-api": "^1.1.0-alpha",

Caret Ranges Allows changes that do not modify the left-most non-zero digit in the [major, minor, patch] tuple. In other words, this allows patch and minor updates for versions 1.0.0 and above...

https://docs.npmjs.com/misc/semver#caret-ranges-123-025-004

gotwarlost commented 8 years ago

I think this is no longer a problem. Closing.