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

files using package word are not included in the coverage report #796

Open
kevinrambaud opened this issue Mar 20, 2018 · 4 comments
Open
Labels

Comments

@kevinrambaud
Copy link

Expected Behavior

I expect nyc to cover all the files that are required by any modules that are tested by mocha.

Observed Behavior

When using the package word into a file, either as a variable name of a function name, nyc just ignore the file and does not report anything for it.

Bonus Points! Code (or Repository) that Reproduces Issue

https://github.com/kevinrambaud/nyc-package-word-empty-coverage-example

Forensic Information

Operating System: the operating system you observed the issue on.
Environment Information: information about your project's environment, see instructions below:

  1. run the following script:

sh -c 'node --version; npm --version; npm ls' > output.txt

  1. share a gist with the contents of output.txt.

https://gist.github.com/kevinrambaud/400048f2bef65a061e6a2859613a23bc

coreyfarrell added a commit to coreyfarrell/nyc that referenced this issue Jun 9, 2018
nyc was hard-coded to use `esModules: true` when running the
instrumenter.  This could result in certain scripts not being
instrumented.

```js
function package() {
  return 'package is a reserved keyword'
}

console.log(package())
```

Using `--es-modules false` will allow this script to be instrumented.

Issue istanbuljs#796
@coreyfarrell
Copy link
Member

@kevinrambaud I've posted a PR to add an option to allow this, but package is a reserved word. Be aware the following script will fail to run:

'use strict';
function package() {
  return 'package is reserved in strict mode';
}
console.log(package());

The addition of 'use strict' causes node.js to refuse the script due to package being reserved.

@kevinrambaud
Copy link
Author

hey @coreyfarrell I forgot to update the issue but I came to the same conclusion after having read the MDN docs https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode thanks for the update

coreyfarrell added a commit to coreyfarrell/nyc that referenced this issue Jun 9, 2018
nyc was hard-coded to use `esModules: true` when running the
instrumenter.  This could result in certain scripts not being
instrumented.

```js
function package() {
  return 'package is a reserved keyword'
}

console.log(package())
```

Using `--es-modules false` will allow this script to be instrumented.

Issue istanbuljs#796
coreyfarrell added a commit to coreyfarrell/nyc that referenced this issue Jun 27, 2018
nyc was hard-coded to use `esModules: true` when running the
instrumenter.  This could result in certain scripts not being
instrumented.

```js
function package() {
  return 'package is a reserved keyword'
}

console.log(package())
```

Using `--es-modules false` will allow this script to be instrumented.

Issue istanbuljs#796
coreyfarrell added a commit to coreyfarrell/nyc that referenced this issue Jun 29, 2018
nyc was hard-coded to use `esModules: true` when running the
instrumenter.  This could result in certain scripts not being
instrumented.

```js
function package() {
  return 'package is a reserved keyword'
}

console.log(package())
```

Add command-line option `--es-modules true` to force strict parsing.

Issue istanbuljs#796
coreyfarrell added a commit to coreyfarrell/nyc that referenced this issue Jul 12, 2018
A previous fix for istanbuljs#796 added an es-modules option and set it false by
default.  This default was a change of behavior in NYC as previously all
sources were parsed as ES modules by the instrumenter.  I believe the
old behavior is the correct default because it allows NYC to work with
modern code.  Code which uses certain features which violate strict mode
will have to disable es-modules.  This will not effect ES5 which follows
the rules of 'use strict'.
coreyfarrell added a commit that referenced this issue Jul 23, 2018
A previous fix for #796 added an es-modules option and set it false by
default.  This default was a change of behavior in NYC as previously all
sources were parsed as ES modules by the instrumenter.  I believe the
old behavior is the correct default because it allows NYC to work with
modern code.  Code which uses certain features which violate strict mode
will have to disable es-modules.  This will not effect ES5 which follows
the rules of 'use strict'.
@stale
Copy link

stale bot commented Jan 6, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 6, 2019
@isaacs
Copy link
Collaborator

isaacs commented Apr 2, 2019

This just popped up again, with the interface keyword.

I think there should never be a case where nyc both (a) doesn't cover a file because of a transpilation error, and (b) says nothing about it. At the very least, a warning should be printed to stderr that coverage could not be added because of ${reason}.

tapjs/tapjs#527

@isaacs isaacs reopened this Apr 2, 2019
@JaKXz JaKXz removed the wontfix label Apr 3, 2019
@stale stale bot added the stale label Jun 2, 2019
@stale stale bot removed the stale label Jun 2, 2019
@istanbuljs istanbuljs deleted a comment from stale bot Jun 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants