Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abresas opened this issue Dec 25, 2015 · 2 comments
Assignees

Comments

@abresas
Copy link

abresas commented Dec 25, 2015

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

  • replace require.extensions['.coffee'] with a getter/setter that always returns coffee-coverage.
  • use https://www.npmjs.com/package/append-transform which makes sure that the last transformation applied is coffee-coverage. That may need a lot of changes.

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
Copy link
Contributor

jwalton commented Jan 2, 2016

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

-Jason

@jwalton jwalton self-assigned this Jan 2, 2016
@brian-mann
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants