nyc: Files get ignored from coverage when esnext bigint is used.

Steps to reproduce.

  1. Have working nyc setup.
  2. Edit a file that already appeared in coverage info, and add the following function:
function foo() {
  return 5n;
}

Result is that the file disappears.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 16 (11 by maintainers)

Most upvoted comments

@kmdrGroch @novemberborn @evert @wzalazar starting with nyc@14.1.0 the bigInt parser is enabled by default. Moving forward we intend to add parser plugins for any stage-3 feature which is supported by any released version of node.js (shortly after the new releases). That means nyc@14.1.0 also supports class properties (public and private).

This new version of nyc version is currently released to npm under next tag for testing.

CC @kmdrGroch @novemberborn @evert @wzalazar FYI in nyc@14.0.0 the option plugins is being renamed to parser-plugins, see #1031. This will be listed under breaking changes in the CHANGELOG.md.

@coreyfarrell as BigInts are in Node.js now, we should probably turn this on by default right?

You do not need nyc to "require": "@babel/register" for this, I’d recommend against it unless you are using babel for other reasons. What you need is to add "plugins": ["bigInt"] to your nyc options. This option expects babel parser plugins, not babel plugins.

If you are still having trouble please post a new ticket with a link to a repository demonstrating the problem.

Ah I see, thanks! Sorry it was the end of my day +1

I think I got that to work. Did have to delete my nyc cache, perhaps plugins are not included in the cache key algorithm?

Glad it’s working for you. .nycrc definitely is not included. I thought that your package.json would be included but looking at the code for caching-transform I’m not confident. Command-line arguments definitely are not included.

Calling this top-level configuration plugins is awfully generic though.

Agreed in hindsight, parser-plugins would have been better. @bcoe @JaKXz can we do anything about this or is it too late? Maybe we can create an alias for now, delete the plugins option from nyc@14?

#948 adds support for configuring the babel parser plugins to be used. This will be included in the next release and will allow you to add the bigInt parser. You can follow #972 for a notification of the next release.

https://babeljs.io/docs/en/babel-parser#plugins