benbria / coffee-coverage

Istanbul and JSCoverage-style instrumentation for CoffeeScript files.
MIT License
145 stars 31 forks source link

Coffee-coverage stops instrumenting files if submodules require coffee-script/register #69

Open abresas opened 8 years ago

abresas commented 8 years ago

coffee-coverage replaces require.extensions['.coffee'] to handle .coffee file compilations itself.

during tests, one of my submodules was requiring coffee-script/register, which led to the original coffee-script handler to compile the files, and coffee-coverage not instrumenting them.

I suspect that this is faced by other users as well. For example the user facing the issue https://github.com/benbria/coffee-coverage/issues/55 uses sprout which has this code https://github.com/carrot/sprout/blob/389799b5fa0eaa10e6f92d002dc1ee3ea3bc0660/lib/template.js#L21.

As you can see from the comments, when jwalton was trying to debug, the last instrumented file was a sprout.coffee.

There are two possible solutions:

I have used the first approach here https://github.com/abresas/register-coffee-coverage, a module that I use as a replacement for my mocha tests, passing --require register-coffee-coverage.

I would prefer this is fixed from coffee-coverage project itself, so I can throw away my wrapper-module .

jwalton commented 8 years ago

Hi @abresas - I'll have a look at this when I'm back in the office on Tuesday the 5th. Happy holidays!

-Jason

brian-mann commented 8 years ago

Also having this problem, which was fixed by https://github.com/abresas/register-coffee-coverage/blob/master/index.js#L5