-
Notifications
You must be signed in to change notification settings - Fork 787
Instrument ES6 generators for coverage #66
Comments
For reference I have a build of the tests that is running with istanbul on travis and the following project can be used to confirm the issue I've configured that project to produce coverage reports using I've also uploaded the resulting coverage report to coveralls. This file does not show coverage for files in my repo & routes folder which are files that include ES6 generators syntax. |
Looks like those are esprima parse errors. The reason most probably is that istanbul depends on esprima 1.0.x and you probably need the 1.1 series of esprima to parse the JS correctly. https://github.com/gotwarlost/istanbul/blob/master/package.json#L34 Could you try with esprima 1.1.x instead and see what happens? The instrumentation may still not be correct but at least the parsing phase should work. |
Hmmm,
I need the guru's help to understand the level of generator support in esprima. /ping @ariya Ariya, is there ES6 generator support in esprima? |
@gotwarlost I have used generators parsing with esprima by depending on |
Running the same code with the ES6 version of esprima gives Transformation error; return original code
[TypeError: Cannot read property 'children' of undefined]
Transformation error; return original code
[TypeError: Cannot read property 'children' of undefined]
Transformation error; return original code
[TypeError: Cannot read property 'children' of undefined]
Transformation error; return original code
[TypeError: Cannot read property 'children' of undefined]
Transformation error; return original code
[TypeError: Cannot read property 'children' of undefined]
Transformation error; return original code
[TypeError: Cannot read property 'children' of undefined]
Transformation error; return original code
{ [Error: Line 13: Illegal yield expression]
index: 347,
lineNumber: 13,
column: 50,
description: 'Illegal yield expression' }
Transformation error; return original code
[TypeError: Cannot read property 'children' of undefined]
Transformation error; return original code
[TypeError: Cannot read property 'children' of undefined]
Transformation error; return original code
[TypeError: Cannot read property 'children' of undefined]
Transformation error; return original code
[TypeError: Cannot read property 'children' of undefined] I suspect that the ast interface has changed in esprima. |
What makes you think this is related to AST interface change? I assume Istanbul's instrumenter needs to be modified to understand those new syntax node. In addition, escodegen also need to recognize it. You can't just feed a foreign node into such a chain of tools and expect everything will still work. |
@ariya you are correct. The esprima interface didn't change. Istanbul has not been configured |
I suppose it's now time to create a |
ping |
I've added yield. It was pretty simple actually, except I'm not sure what's the best way to make test for it ES6-only. |
Nice work! Could you create PR for this? |
This change is now on the istanbul harmony branch which in turn has an npm git dependency on the esprima harmony branch |
baller! |
For now: add this dependency to devDependencies: "istanbul": "git://github.com/gotwarlost/istanbul.git#harmony", this will install istanbul from harmony branch. Good for me 👍 |
There's also a istanbul-harmony package. It's rather old, could there be a merge from master? |
harmony branch is now 152 commits behind master. alternatives? |
I tried configuring Istanbul in my ember-cli application. And End up in getting the error of the same kind. Below is the details of the error. |
I just want to 👍 this. Generators are amazing and should be supported, and not on an outdated harmony branch |
👍 - also experiencing issue |
arrow functions work with istanbul version 0.3.14, but 'import' and 'export' usage gives error: Unexpected reserved word because esprima version is still 2.1.x. esprima 2.2 supports import and export. Any plans for new istanbul version that leverages esprima 2.2? |
+1 @kinshuk |
@kinshuk - could you try the latest version of istanbul that uses the latest stable esprima? Please close this issue if it is not a problem any more. The harmony branch is now defunct and mainline has everything the harmony branch has and more. |
Still seems unhappy... $ ./node_modules/.bin/istanbul instrument test.js $ cat test.js export default { Digging deeper, it seems esprima wants sourceType = module I added "sourceType: 'module'" in ESP.parse call in instrumenter.js, but esprima died with a different error... |
I've just converted a es5 project to es6 syntax including The coverage can be done, but it was logging something I don't understand.....
|
Fore those coming by and looking for a fix, istanbul@1.0.0-alpha.2 fixed this for me: https://github.com/gotwarlost/istanbul/releases/tag/v1.0.0-alpha.2 |
@davidrapin Thx for your suggestion! |
When using istanbul on ES6 code it prints a bunch of errors
The result is that every piece of code I have that uses generators is not instrumented.
The text was updated successfully, but these errors were encountered: