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


source to share





All Articles