Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Feature: Code coverage/instrumentation #95

Closed
GeoffreyBooth opened this issue May 19, 2018 · 4 comments
Closed

Feature: Code coverage/instrumentation #95

GeoffreyBooth opened this issue May 19, 2018 · 4 comments
Labels

Comments

@GeoffreyBooth
Copy link
Member

  • I want to write a code coverage tool that gathers great data about both ESM and CommonJS imports.
  • My code coverage tool is able to retrieve data about ESM modules on par with what is available about CommonJS modules.

Use cases 3, 11.

@coreyfarrell
Copy link
Member

As a maintainer of NYC I'd like to ensure that we can provide coverage for ESM modules. For CJS modules by default we hook require.extensions, we also have the ability to hook vm.runInThisContext and vm.runInContext. In all of these methods we add instrumentat (coverage counters) to the code before passing it to the original method.

We need a similar ability to support native ESM. Currently to test ESM with nyc can only be done by having babel transpile to commonjs or by using --require esm.

@jkrems
Copy link
Contributor

jkrems commented Apr 1, 2019

Would it be possible for nyc to use the native V8 coverage info for ESM files? That way it may get away with not transforming the code. I assume the version of node that ships ESM would also have proper support for those APIs already.

@coreyfarrell
Copy link
Member

c8 uses native V8 coverage. I just gave this a try with c8 node --experimental-modules ./bin.mjs, I did not get any coverage (tested with node 10.15.3 and 11.13.0).

In either case c8 is a different project from nyc. Native V8 coverage is very promising but IMO it's not ready to replace nyc.

@Flarna
Copy link
Member

Flarna commented Jun 11, 2019

I think even if nyc could be ported to use v8 coverage there are other tools (transpilers, APM,...) which have the same/similar need.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants