istanbuljs / istanbuljs/istanbuljs.github.io
nyc silently fails with this weird code
- Dominant language
- JavaScript
- Stars
- 25
- Forks
- 22
- PR merge metrics
- No merged PRs in 30d
Description
## 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
```js
/** @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
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the provided weird.js reproduction with Node v8.10.0 and nyc 11.6.0, then compare it with the version where `arguments` is renamed to `args`. Trace why nyc reports zero coverage instead of an error; done means the invalid syntax produces a meaningful failure rather than a silent zero-coverage report.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100