jeffrifwald / babel-istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
144 stars 23 forks source link

Exclude pattern failing #42

Closed Jerska closed 8 years ago

Jerska commented 8 years ago

Hi,

First of all, thanks for this great tool!

Now, for my issue, I'm running babel-istanbul with mocha. The command

BABEL_ENV=test babel-node node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha -- ...

works fine.

However, if I try to use an exclude pattern:

BABEL_ENV=test babel-node node_modules/.bin/babel-istanbul cover -x "**/__tests__/**" node_modules/.bin/_mocha -- ...

I got an error as if the code wasn't transpiled:

import React from 'react';
^^^^^^

SyntaxError: Unexpected reserved word
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:414:25)
    at Object.Module._extensions..js (module.js:442:10)
    at Object.Module._extensions.(anonymous function) [as .js] (absolute_path_to_my_project/node_modules/babel-istanbul/lib/hook.js:109:37)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at absolute_path_to_my_project/node_modules/mocha/lib/mocha.js:216:27
    at Array.forEach (native)
    at Mocha.loadFiles (absolute_path_to_my_project/node_modules/mocha/lib/mocha.js:213:14)
    at Mocha.run (absolute_path_to_my_project/node_modules/mocha/lib/mocha.js:453:10)
    at Object.<anonymous> (absolute_path_to_my_project/node_modules/mocha/bin/_mocha:393:18)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Object.Module._extensions.(anonymous function) [as .js] (absolute_path_to_my_project/node_modules/babel-istanbul/lib/hook.js:109:37)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at runFn (absolute_path_to_my_project/node_modules/babel-istanbul/lib/command/common/run-with-cover.js:125:16)
    at absolute_path_to_my_project/node_modules/babel-istanbul/lib/command/common/run-with-cover.js:258:17
    at absolute_path_to_my_project/node_modules/babel-istanbul/lib/util/file-matcher.js:68:16
    at absolute_path_to_my_project/node_modules/babel-istanbul/node_modules/async/lib/async.js:52:16
    at absolute_path_to_my_project/node_modules/babel-istanbul/node_modules/async/lib/async.js:361:13
    at absolute_path_to_my_project/node_modules/babel-istanbul/node_modules/async/lib/async.js:52:16
    at done (absolute_path_to_my_project/node_modules/babel-istanbul/node_modules/async/lib/async.js:246:17)
    at absolute_path_to_my_project/node_modules/babel-istanbul/node_modules/async/lib/async.js:44:16
    at absolute_path_to_my_project/node_modules/babel-istanbul/node_modules/async/lib/async.js:358:17
    at LOOP (fs.js:1539:14)
    at doNTCallback0 (node.js:417:9)
    at process._tickDomainCallback (node.js:387:13)

I'm using babel-istanbul@0.5.9. Any idea? :)

jeffrifwald commented 8 years ago

This is still a mystery to me as I haven't had time to really look at it, but see the following closed issue:

https://github.com/ambitioninc/babel-istanbul/issues/28