Comments (27)
Fore those coming by and looking for a fix, [email protected] fixed this for me: https://github.com/gotwarlost/istanbul/releases/tag/v1.0.0-alpha.2
from istanbul.
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 npm run cover
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.
from istanbul.
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.
from istanbul.
Hmmm,
$ npm info esprima versions
[ '0.7.0',
'0.8.0',
'0.8.1',
'0.8.2',
'0.9.0',
'0.9.1',
'0.9.2',
'0.9.3',
'0.9.4',
'0.9.5',
'0.9.6',
'0.9.7',
'0.9.8',
'0.9.9',
'1.0.0',
'1.0.1',
'1.0.2',
'1.0.3' ]
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?
from istanbul.
@gotwarlost I have used generators parsing with esprima by depending on ariya/esprima#harmony
. i.e. there is a harmony git branch that will parse them. I can try changing to that and seeing what istanbul does.
from istanbul.
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.
from istanbul.
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.
from istanbul.
@ariya you are correct.
The esprima interface didn't change. Istanbul has not been configured YieldExpression
in it's ast tree walker implementation and thus does not know how to handle it.
from istanbul.
I suppose it's now time to create a harmony
branch for istanbul :)
from istanbul.
ping
from istanbul.
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.
from istanbul.
Nice work! Could you create PR for this?
from istanbul.
@meritt I'm not sure it's ready yet, but there you go: #129
from istanbul.
This change is now on the istanbul harmony branch which in turn has an npm git dependency on the esprima harmony branch
from istanbul.
baller!
from istanbul.
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
from istanbul.
There's also a istanbul-harmony package. It's rather old, could there be a merge from master?
from istanbul.
harmony branch is now 152 commits behind master. alternatives?
from istanbul.
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.
group-test file contains the test cases and applied istanbul on that file. I tried with different approches like downgrading the Istanbul
version,using the code from harmony branch both i end up in getting the same exception.
Any inputs in related to resolving this issue will be very much helpful and appreciated.
D:\codecoverage\istanbul_kafka_1\tests\unit>istanbul cover group-test.js
Transformation error; return original code
{ [Error: Line 1: Unexpected reserved word]
index: 15,
lineNumber: 1,
column: 16,
description: 'Unexpected reserved word' }
No coverage information was collected, exit without writing coverage information
D:\codecoverage\istanbul_kafka_1\tests\unit\group-test.js:1
(function (exports, require, module, __filename, __dirname) { import { test, m
^^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Object.Module._extensions.(anonymous function) as .js
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at runFn (C:\Users\pavan\AppData\Roaming\npm\node_modules\istanbul\lib\command\common\run-with-cover.js:122:16)
at C:\Users\pavan\AppData\Roaming\npm\node_modules\istanbul\lib\command\common\run-with-cover.js:248:17
at C:\Users\pavan\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-matcher.js:68:16**
from istanbul.
I just want to
from istanbul.
from istanbul.
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?
from istanbul.
+1 @kinshuk
from istanbul.
@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.
from istanbul.
Still seems unhappy...
$ ./node_modules/.bin/istanbul instrument test.js
/tmp/node_modules/istanbul/node_modules/esprima/esprima.js:5474
throw e;
^
Error: Line 3: Unexpected token
at createError (/tmp/node_modules/istanbul/node_modules/esprima/esprima.js:2336:21)
at unexpectedTokenError (/tmp/node_modules/istanbul/node_modules/esprima/esprima.js:2411:13)
at tolerateUnexpectedToken (/tmp/node_modules/istanbul/node_modules/esprima/esprima.js:2420:21)
at parseStatementListItem (/tmp/node_modules/istanbul/node_modules/esprima/esprima.js:3814:21)
at parseFunctionSourceElements (/tmp/node_modules/istanbul/node_modules/esprima/esprima.js:4649:23)
at parseFunctionExpression (/tmp/node_modules/istanbul/node_modules/esprima/esprima.js:4859:16)
at parsePrimaryExpression (/tmp/node_modules/istanbul/node_modules/esprima/esprima.js:3167:24)
at inheritCoverGrammar (/tmp/node_modules/istanbul/node_modules/esprima/esprima.js:2592:18)
at parseLeftHandSideExpressionAllowCall (/tmp/node_modules/istanbul/node_modules/esprima/esprima.js:3292:20)
at inheritCoverGrammar (/tmp/node_modules/istanbul/node_modules/esprima/esprima.js:2592:18)
$ cat test.js
'use strict';
export default {
bar: 22
};
Digging deeper, it seems esprima wants sourceType = module
3809: function parseStatementListItem() {
3810: if (lookahead.type === Token.Keyword) {
3811: switch (lookahead.value) {
3812: case 'export':
3813: if (sourceType !== 'module') {
3814: tolerateUnexpectedToken(lookahead, Messages.IllegalExportDeclaration);
I added "sourceType: 'module'" in ESP.parse call in instrumenter.js, but esprima died with a different error...
from istanbul.
I've just converted a es5 project to es6 syntax including class
, super
.
The coverage can be done, but it was logging something I don't understand.....
{ range: [ 646, 651 ],
loc:
SourceLocation {
start: Position { line: 34, column: 6 },
end: { line: 34, column: 11 } },
type: 'Super' }
Unsupported node type:Super
Transformation error; return original code
[TypeError: this[type] is not a function]
{ range: [ 618, 623 ],
loc:
SourceLocation {
start: Position { line: 26, column: 10 },
end: { line: 26, column: 15 } },
type: 'Super' }
Unsupported node type:Super
Transformation error; return original code
[TypeError: this[type] is not a function]
{ range: [ 172, 177 ],
loc:
SourceLocation {
start: Position { line: 7, column: 4 },
end: { line: 7, column: 9 } },
type: 'Super' }
Unsupported node type:Super
Transformation error; return original code
[TypeError: this[type] is not a function]
{ range: [ 816, 821 ],
loc:
SourceLocation {
start: Position { line: 23, column: 4 },
end: { line: 23, column: 9 } },
type: 'Super' }
Unsupported node type:Super
{ range: [ 1376, 1381 ],
loc:
SourceLocation {
start: Position { line: 45, column: 6 },
end: { line: 45, column: 11 } },
type: 'Super' }
Unsupported node type:Super
Transformation error; return original code
[TypeError: this[type] is not a function]
{ range: [ 363, 368 ],
loc:
SourceLocation {
start: Position { line: 13, column: 4 },
end: { line: 13, column: 9 } },
type: 'Super' }
Unsupported node type:Super
Transformation error; return original code
[TypeError: this[type] is not a function]
{ range: [ 521, 526 ],
loc:
SourceLocation {
start: Position { line: 22, column: 4 },
end: { line: 22, column: 9 } },
type: 'Super' }
Unsupported node type:Super
{ range: [ 1635, 1640 ],
loc:
SourceLocation {
start: Position { line: 66, column: 11 },
end: { line: 66, column: 16 } },
type: 'Super' }
Unsupported node type:Super
{ range: [ 1771, 1776 ],
loc:
SourceLocation {
start: Position { line: 74, column: 11 },
end: { line: 74, column: 16 } },
type: 'Super' }
Unsupported node type:Super
Transformation error; return original code
[TypeError: this[type] is not a function]
{ range: [ 559, 564 ],
loc:
SourceLocation {
start: Position { line: 15, column: 4 },
end: { line: 15, column: 9 } },
type: 'Super' }
Unsupported node type:Super
Transformation error; return original code
[TypeError: this[type] is not a function]
{ range: [ 362, 367 ],
loc:
SourceLocation {
start: Position { line: 17, column: 4 },
end: { line: 17, column: 9 } },
type: 'Super' }
Unsupported node type:Super
{ range: [ 1870, 1875 ],
loc:
SourceLocation {
start: Position { line: 75, column: 13 },
end: { line: 75, column: 18 } },
type: 'Super' }
Unsupported node type:Super
{ range: [ 2035, 2040 ],
loc:
SourceLocation {
start: Position { line: 81, column: 11 },
end: { line: 81, column: 16 } },
type: 'Super' }
Unsupported node type:Super
{ range: [ 2088, 2093 ],
loc:
SourceLocation {
start: Position { line: 85, column: 4 },
end: { line: 85, column: 9 } },
type: 'Super' }
Unsupported node type:Super
Transformation error; return original code
[TypeError: this[type] is not a function]
{ range: [ 183, 188 ],
loc:
SourceLocation {
start: Position { line: 8, column: 4 },
end: { line: 8, column: 9 } },
type: 'Super' }
Unsupported node type:Super
Transformation error; return original code
[TypeError: this[type] is not a function]
from istanbul.
@davidrapin Thx for your suggestion!
from istanbul.
Related Issues (20)
- Zero coverage from export only files HOT 3
- 100% code coverage with no line numbers
- Content-Security-Policy unsafe-eval HOT 1
- `istanbul cover` hiding errors with octal literals
- ignore lines of code by specifying the line numbers HOT 1
- Function to string without istanbul in runtime HOT 1
- Looking for Constantinople.js HOT 1
- is it possible to apply the effect from /* istanbul ignore next */ to all typescript private methods automagically?
- option to disable coverage on import lines
- Open Coverage File Automatically on Test Command? HOT 2
- Branches that don't exist get reported as missing
- how to use istanbul as a library
- Analyzing coverage of node server in Windows HOT 1
- exclude imported node modules from coverage reporting HOT 1
- Cannot get the backend coverage by running Cypress UI e2e test HOT 1
- Ignore implied "else"
- Coverage format documentation not explicitly stating 'end' meaning HOT 1
- Istanbul doesn't ignore nested if, when not executed
- Async package is vulnerable
- Coverage not being collected from file called "payload.ts"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from istanbul.