Skip to content

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

@abresas

Description

@abresas

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 .

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions