mardi 31 mars 2015

How to include required files in Istanbul that are not in same directory as test case?

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!


Aucun commentaire:

Enregistrer un commentaire