pocesar/grunt-mocha-istanbul

is there a way to disable instrumentation?

Closed this issue · 3 comments

travi commented

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.

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

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.

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 :)