How to use dynamically loaded files in Istanbul to encode Mocha code?

I am loading JS into my Mocha test at runtime using fs and vm.runInThisContext:

fs.readFile(path, {encoding: 'utf8'}, function(error, data){})
....
vm.runInThisContext( code );

      

but when i run istanbul like this

$ istanbul cover --hook-run-in-context node_modules/mocha/bin/_mocha -- --recursive -R spec
...
fake test
 should pass

3 passing (28ms)

No coverage information was collected, exit without writing coverage information

      

Is there any documentation on how to use the -hook-run-in-context command to get the code for these files? I'm wondering if there might be some kind of incompatibility between Mocha, Istanbul and the most recent version of Node I'm running.

(Windows 7 with Git Bash)

$ node -v && npm -v
v0.12.2
2.7.4

$ npm list -g mocha
C:\Users\212309975\AppData\Roaming\npm
└── mocha@2.2.4

      

+3
node.js unit-testing mocha istanbul


source to share


No one has answered this question yet

See similar questions:

15
Istanbul code coverage for Mocha tests

or similar:

188
Code coverage with Mocha
22
How to get code coverage information with Node, Mocha
8
Istanbul gives me coverage but ends up with an error
2
Enzyme and mocha are giving me error for dough in Istanbul why?
2
Istanbul: no coverage information was collected, exit without recording coverage information
1
"npm run coverage" does not work with mocha
1
How to set up istanbul reach report to exclude specific sources?
0
Crash report generation: mocha> gulp-mocha> gulp-itanbul
0
Istanbul does not generate coverage for mocha-chi and chai-http test



All Articles
Loading...
X
Show
Funny
Dev
Pics