0

I'm trying to do something simple, but it's not working.. I must be doing something dumb.

I am using Istanbul with Mocha for code coverage + unit testing.

In the code being tested, it is using functions from modules which are being require'd, and I want those imported modules to be included in the code coverage - but it's not.

I am explicitly including a library from a require with a full path to it (it is not the same dir as where the test case resides)

var d = require(srcroot + '/scripting/wf_daemon/daemon_lib');

And then later, the test case is making a call to a function in that module startWorkFlow.

d.startWorkflow(workflow, function (msg) { // do something })

However, Istanbul does not go into the referenced function startWorkFlow, it only gives me coverage for the test file.

What I need is code coverage to extend into all functions from the modules require'd by the test case.

I am calling Istanbul like this:

istanbul cover --include-all-source --dir C:\Build\buildarea --print none "C:\Program Files\nodejs\node_modules\mocha/bin/_mocha" -- --reporter mocha-teamcity-reporter ./test.js

Is there any way to get Istanbul to instrument the files which are not in the directory (or subdirectories) where the test case resides? What simple mistake am I making?

Cheers!

Stretch
  • 3,669
  • 2
  • 28
  • 40
  • It's sort of late for me so I'm probably wrong, but what if you pass the `--preload-sources` as a parameter to the `cover` command? – Justin Maat Apr 01 '15 at 04:02
  • Also , shouldn't it be `--include-all-sources` (note the 's' suffix) , and shouldn't that be before the `cover` command (ie `istanbul --include-all-sources cover --preload-sources ...` – Justin Maat Apr 01 '15 at 04:04
  • thanks - I was missing an "s".. the `--preload-sources` is deprecated I discovered (thought that might be it!), it's the `--include-all-sources` command now. However, it didn't work.. still doesn't include my libraries.. :( – Stretch Apr 01 '15 at 05:23

0 Answers0