douglasduteil / isparta

:skull: A code coverage tool for ES6 (babel/6to5)
Do What The F*ck You Want To Public License
643 stars 47 forks source link

Transformation error; return original code #68

Open almeynman opened 8 years ago

almeynman commented 8 years ago

Hello,

when I run

babel-node node_modules/.bin/isparta cover --report html node_modules/.bin/_mocha -- --recursive

I get the following error:

Transformation error; return original code
{ [Error: Line 1: Unexpected token ILLEGAL]
  lineNumber: 1,
  description: 'Unexpected token ILLEGAL',
  index: 0 }
Creating a pool connected to localhost:28015

Although tests pass and report is generated after the error...

I downgraded from 3.0.4 to 3.0.2 and error disappered.

Thanks

gausie commented 8 years ago

I am also experiencing this error.

impy88 commented 8 years ago

+1

mtlima commented 8 years ago

+1

razvanip commented 8 years ago

+1

hden commented 8 years ago

Using the .istanbul.yml from https://github.com/douglasduteil/isparta/issues/47#issuecomment-121014224 solves it.

douglasduteil commented 8 years ago

I'll have to investigate if I can solve this without .istanbul.yml

douglasduteil commented 8 years ago

Similar to #47

kishorevarma commented 8 years ago

I am also facing the same issue +1

douglasduteil commented 8 years ago

Hi @almasakchabayev

After some code surfing :surfer: I found out that the problem comes form the istanbul default exclusion pattern that don't match for node_modules/.bin/_mocha

Here is deduction http://tonicdev.com/douglasduteil/isparta-68-transformation-error-return-original-code

kishorevarma commented 8 years ago

I am still facing same issue, even though I have changed as you mentioned

 babel-node ./node_modules/.bin/isparta cover ./node_modules/mocha/bin/_mocha -- --require ./tests/test_helper.js tests/**/*.js
Transformation error; return original code
{ [Error: Line 1: Unexpected token ILLEGAL]
  lineNumber: 1,
  description: 'Unexpected token ILLEGAL',
  index: 0 }

.babelrc

{
  "presets": ["es2015"]
}
douglasduteil commented 8 years ago

Aie @kishorevarma I :up: the below TonicDev ./node_modules/mocha/bin/_mocha is not working either (ಠ ∩ಠ)

kishorevarma commented 8 years ago

@douglasduteil , oh yeah I missed that part in TonicDev , yeah now I am using as follow

 babel-node ./node_modules/.bin/isparta cover node_modules/mocha/bin/_mocha -- --require ./tests/test_helper.js tests/**/*.js

but now there is no error, its silently exiting, when I change .babelrc to as follow, it actually run the tests but won't generate the report because stage option not recognisable (unknown option)

{ "stage: 0 }

so If I am using as follow, it not running tests and not giving report and not giving error :(

 {
    "presets": ["es2015"]
 }
kishorevarma commented 8 years ago

@douglasduteil ignore I think its some problem with babel versions. I will try to find out the issue thanks :)

kishorevarma commented 8 years ago

@douglasduteil, I sorted out the issues but got struck with decorators trnasformation in babel 6. but the above issue got resolved thanks, I am using with out babel-node as shown in your example node_modules/.bin/isparta cover --verbose --include-all-sources --excludes '**<some folder>**' --report lcov --report html node_modules/mocha/bin/_mocha -- tests/**/*.js

Thanks Kishore

ngduc commented 8 years ago

I have the same issue, tried all above tips but they didn't work for me. Is this fixed yet? Thanks.

chimico commented 8 years ago

+1

tarciosaraiva commented 8 years ago

I have the same issue but it doesn't seem to affect the end result. Here's the command I'm running:

./node_modules/.bin/babel-node ./node_modules/.bin/isparta cover --report lcov ./node_modules/mocha/bin/_mocha -- ./test/unit

What I found is that by adding the configuration below to .istanbul.yml fixes it, as if telling ispartan to look for the files to instrument.

instrumentation:
  root: <src_dir>

That did the trick for me.

pvdz commented 8 years ago

FYI;

The reason (as described above) is a default inclusion pattern.

The solution is passing on a root where files are checked only. This may also speed up the whole thing depending on your setup (since it won't have to cover your entire repo but just your source files).

You also don't need a yml file for this as root is a cli param;

./node_modules/.bin/babel-node ./node_modules/.bin/isparta cover --root src/  ./node_modules/mocha/bin/_mocha -- ./test/unit 
montogeek commented 8 years ago

@qfox Your solution worked, thank you :)

ngduc commented 8 years ago

@montogeek @qfox solution does not work for me. This command works for me:

NODE_PATH=./src babel-node $(npm bin)/isparta cover --verbose --report text --report html $(npm bin)/_mocha -- --require ./tools/test/test-init src/**/*.spec.js

https://github.com/ngduc/react-setup/blob/master/package.json

mwshortt commented 8 years ago

@qfox Thank you so much! Your solution works for me. That error was driving me crazy. Also after adding that my coverage went up by 6%, has anyone else seen a coverage spike like that upon fixing this error?

rodoabad commented 8 years ago

This is still going on for me.

"coverage": "babel-node ./node_modules/isparta/bin/isparta cover --report html ./node_modules/mocha/bin/_mocha -- test/unit",

niftylettuce commented 8 years ago

It is now working with istanbul@^1.1.0-alpha.1. See my setup here https://github.com/niftylettuce/koa-ratelimit-promises and my code coverage report here https://codecov.io/gh/niftylettuce/koa-ratelimit-promises. Thanks!

ziyofun commented 6 years ago

undering mocha@3.5.3 and istanbul@1.1.0-alpha.1, I find that if variable's name is same as function's name will throw this error. such as:

function foo() {
    const foo = 'bar';
}