Skip to content
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

nyc silently fails with this weird code #139

Open
hyrsky opened this issue Mar 26, 2018 · 1 comment
Open

nyc silently fails with this weird code #139

hyrsky opened this issue Mar 26, 2018 · 1 comment

Comments

@hyrsky
Copy link

hyrsky commented Mar 26, 2018

Observed Behavior

I was working an a small side project today and had a frustrating experience with nyc. After everything I tried all i got for output was:

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|

My code had function like this: function myFunc(obj, ...arguments). Turns out arguments is a reserved keyword that does exactly the thing I was trying to do! 😄 I discovered this when I added 'use strict' to my code and node gave an error. I'm not sure if this case is within the scope of this project but anyway I wanted to document this in case someone else is struggling with similar problem!

Expected Behavior

Nyc should fail with a meaningful error message.

Bonus Points! Code (or Repository) that Reproduces Issue

/** @file: weird.js */

function myFunc(obj, ...arguments) {
    console.log('Hello world!');
}

myFunc({}, 'foo', 'bar');
╭─user@computer ~/Documents/test
╰─$ node weird.js
Hello world!
╭─user@computer ~/Documents/test
╰─$ yarn run nyc node weird.js
yarn run v1.5.1
$ /mnt/c/Users/User/Documents/test/node_modules/.bin/nyc node weird.js
Hello world!
----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|
Done in 3.51s.

Rename arguments to args and everything works as it should.

Forensic Information

Operating System: Ubuntu on Windows subsystem for linux.
Node version: v8.10.0
Nyc version: 11.6.0
Yarn version: 1.5.1

@JaKXz JaKXz transferred this issue from istanbuljs/nyc Jan 10, 2019
@JaKXz
Copy link
Member

JaKXz commented Jan 10, 2019

Thanks for this issue, and sorry for the late reply! I appreciate the documentation, and I think it could be captured on the wiki site in a gotchas/troubleshooting section. Feel free to make a PR if you are able.

@istanbuljs istanbuljs deleted a comment from stale bot Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants