Open almeynman opened 8 years ago
I am also experiencing this error.
+1
+1
+1
Using the .istanbul.yml
from https://github.com/douglasduteil/isparta/issues/47#issuecomment-121014224 solves it.
I'll have to investigate if I can solve this without .istanbul.yml
Similar to #47
I am also facing the same issue +1
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
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"]
}
Aie @kishorevarma
I :up: the below TonicDev
./node_modules/mocha/bin/_mocha
is not working either (ಠ ∩ಠ)
@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"]
}
@douglasduteil ignore I think its some problem with babel versions. I will try to find out the issue thanks :)
@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
I have the same issue, tried all above tips but they didn't work for me. Is this fixed yet? Thanks.
+1
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.
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
@qfox Your solution worked, thank you :)
@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
@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?
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",
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!
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';
}
Hello,
when I run
I get the following error:
Although tests pass and report is generated after the error...
I downgraded from 3.0.4 to 3.0.2 and error disappered.
Thanks