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

Feature Request: Code Coverage #11

Open
mlrawlings opened this issue Apr 7, 2019 · 1 comment
Open

Feature Request: Code Coverage #11

mlrawlings opened this issue Apr 7, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@mlrawlings
Copy link

It would be really nice to get coverage reports by using nyc:

nyc puppet-run plugin:mocha [...mocha options] ./path/to/*.test.js

nyc automatically instruments the code running in the node process (and any subprocesses), but the bundled code will not be instrumented.

Potential implementation

I've actually worked on a similar tool which also bundles code and runs it in the browser and reports back to the console. We implemented nyc support by:

  1. Checking if the runner was started by nyc
  2. Adding an instrument plugin to the bundler
  3. Grabbing the window.__coverage__ variable which the instrumenting reports to and sending it back to the server

With puppet-run, 1 and 3 would remain conceptually the same, but as far as I can tell, Parcel doesn't have an instrumentation plugin. I'm also unsure if it's possible to conditionally apply plugins.

I think the better solution might be to instrument the code after it goes through parcel and rely on sourcemaps to get accurate code coverage. babel-plugin-istanbul supports passing an inputSourcemap so the sourcemaps output by Parcel could be passed along.

@andywer andywer added the enhancement New feature or request label Apr 7, 2019
@andywer
Copy link
Owner

andywer commented Apr 7, 2019

Hey @mlrawlings!

That's a fair feature request. I would propose a different approach though:

  • Let's use puppeteer to capture the code coverage via the Chromium built-in coverage feature
  • Use puppeteer-to-istanbul to convert the coverage data

Maybe you are in the mood for a little contribution? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants