New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Readme clarification request: does not work with ES6 #916
Comments
I also recently started using nyc with non-babelified node code, only to discover by trial-and-error that it fails in weird ways with ES6 syntax (e.g., gives 0% branch coverage when there's a default parameter). 😫 A couple of improvements I would suggest:
|
@Lukenickerson I would love to see that! We have https://github.com/istanbuljs/istanbuljs.github.io for our |
@papb Regarding the stack trace error locations, this is documented at https://github.com/istanbuljs/nyc#accurate-stack-traces-using-source-maps. My understanding is that there are difficulties with this functionality, that would be an actual code bug (unclear where). I do not believe this would have anything to do with ES6, though I'd be willing to look at an example showing that I'm wrong. @Lukenickerson I'm not sure what ES6 features are not working for you. I've just created the following code: function test(value = 'default') {
console.log(value);
}
test('test'); And run:
The 0% branch coverage for this code is expected. If I replace |
@coreyfarrell - Thanks for the update, sorry I didn't reply any sooner, I have been very busy, will take a look later. Thanks :) |
This has been fixed as of #1093. |
The ES6 syntax default function parameters cause 0% branch coverage sometimes. So first i deleted the syntax and nyc's coverage was expected, then i added it again and the coverage was also correct. It is so weird. Seems no problem, i just say my exprience. |
Summary
It appears that nyc does not work out of the box with ES6. The readme makes it seem like a few plugins might be necessary if one is using Babel. I'm not using Babel, I'm simply using ES6 directly in Node.
My goal opening this issue is to suggest improvements to README.md:
The steps below indicate what a beginner could try to do, not even knowing what "babel" means:
Steps to reproduce
npm init -y && npm install mocha nyc
index.js
with the following content:test.js
with the following content:nyc mocha
Expected Behavior
Observed Behavior
Forensic Information
Operating System: Windows 7
Environment Information:
Notes
This is a honest opinion that README.md could be better, especially for non-experts trying to use this great library. Currently the information is scattered in complicated "transform", "babel plugins", with only superficial instructions. Please try to take a look at README.md from the point of view of a beginner (ideally, one that doesn't even know what Babel is).
I, for instance, was a bit frustrated that I had to go through all this until I figured out what was going on...
Thanks for looking 😀
The text was updated successfully, but these errors were encountered: