pocesar / grunt-mocha-istanbul

Almost config-free Istanbul code coverage reporter for Mocha usage in Grunt
MIT License
75 stars 23 forks source link

is there a way to disable instrumentation? #58

Closed travi closed 8 years ago

travi commented 8 years ago

Is istanbul instrumentation required for all tasks defined for this runner?

I'd like to calculate coverage for my default build, but not during a tdd cycle since the instrumentation is pretty slow. I tried the obvious things like setting coverage to false but it is still slow enough that I assume it is still taking the instrumentation hit.

Worst case, I can add a second mocha plugin, but I'd like to group the tasks under a single plugin definition.

pocesar commented 8 years ago

sorry, the plugin is tied to coverage information, the test only happen so the source can be instrumented and coverage'd. all paths, regardless of options, use istanbul (be it the mocha_istanbul task or the check_coverage task) one thing that you could do, and would be an awful hack IMHO, is to change the scriptPath option to a passthrough node.js bin, that would take stdin and make it stdout on the command given after cover, so the executed task would be like node yourpassthrough.js cover node_modules/mocha/bin/_mocha -- test

and yourpassthrough.js would look like (haven't tested!):

var spawn = require("child_process").spawn;

spawn(process.execPath, process.argv.slice(1), {
  cwd: process.cwd(),
  stdio: 'inherit'
})
travi commented 8 years ago

ok no worries. i certainly don't need to go as far as hacking something together. i'll just add in another grunt plugin that can run mocha tests w/o the coverage. simply not as convenient as i was hoping for.

thank you for the quick response and clarification.

pocesar commented 8 years ago

just noticed there's a task that does this (combines 2 grunt plugins into one)

https://github.com/smulyono/grunt-node-mocha

I know it's a bit late, but might serve for future reference :)