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

Babel 6 support #32

Closed gajus closed 8 years ago

gajus commented 8 years ago

https://babeljs.io/blog/2015/10/29/6.0.0/

thealjey commented 8 years ago

Hi! I know that this is probably not the best place to ask a question like that. But since there's no Babel 6 support yet (and I want it real bad) and since babel-istanbul is supposed to be a drop in replacement, I figured I could just use istanbul on the code compiled with Babel 6 (I thought it'd be basically the same thing). So, I went from this (worked perfectly with Babel 5):

babel-istanbul cover --root lib --print detail --include-all-sources jasmine

to this:

istanbul cover --root build --print detail --include-all-sources jasmine

However, even though all of my 179 specs are still passing (jasmine has no problem finding them), istanbul prints "No coverage information was collected, exit without writing coverage information" and does nothing. Sorry for bothering.

jeffrifwald commented 8 years ago

There are some pretty nasty bugs in Babel 6, so I'm waiting on some semblance of stability in the plugin/preset system before I start digging in with this package. I'd assume sometime next week things will calm down over there.

@thealjey I'm not sure how your jasmine specs are set up, but I am assuming either jasmine or istanbul is just looking in the wrong spot for your build files.

thealjey commented 8 years ago

Well, that's the thing, Babel 6 works just fine now (at least the parts that I'm using), I've checked. Also, all of my tests are still passing. As to the setup, there isn't much more of it than I already wrote about. I have 3 directories - lib (source files), build (Babel compiled files), spec (*Spec.js specs).

  1. files are compiled with
babel lib --out-dir build --presets es2015,stage-2,react --plugins transform-react-display-name,transform-runtime
  1. the tests are executed with
istanbul cover --root build --print detail --include-all-sources jasmine

that is it, nothing more to it istanbul finds the files under --root, passes them on to jasmine, which successfully executes all of the tests but then, all of a sudden, it says that no coverage information was collected :open_mouth:

thealjey commented 8 years ago

I figured it out, turns out you need to specify --root for both istanbul and jasmine (one more "build" at the end):

istanbul cover --root build --print detail --include-all-sources jasmine build

However, I have a new problem now, istanbul now wants me to cover "_interopRequireDefault", "__esModule" and the rest of the Babel noise. It also reports that code inside class constructor functions, methods defined as {key: ..., value: ...} and other completely random things (which are definitely covered, I've always had 100% coverage on the project) are not covered.

So, it seems that you are my only hope, I'm very impatient, but I'll wait :blush: I didn't realize how important babel-istanbul was to me until I couldn't use it any more.

thealjey commented 8 years ago

I can't believe I could be so dumb/blind, the only thing that does not currently work with babel-istanbul is "--include-babel-polyfill" and that doesn't seem all that important, cause everything works just fine without it. So, I'm back at 100% percent coverage, using babel-istanbul again, and couldn't be happier :smile: I won't be spamming you guys any more, promise :blush:

jeffrifwald commented 8 years ago

0.5.5 should be up to date with babel 6 support. Big change is there are no longer command line flags for babel options. We'll have to use .babelrc files from here on out since the plugin system it has gotten too complicated to address with command line arguments now.