andywer / andywer/puppet-run

Feature Request: Code Coverage

Đang mở
#11 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
TypeScript
Star
56
Fork
2
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

It would be really nice to get coverage reports by using [`nyc`](https://github.com/istanbuljs/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](https://github.com/marko-js/cli/blob/master/packages/test) which also bundles code and runs it in the browser and reports back to the console. We implemented `nyc` support by:

1. [Checking](https://github.com/marko-js/cli/blob/master/packages/test/src/util/browser-tests-runner/bundler.js#L7) if the runner was started by `nyc`
2. Adding an [instrument plugin](https://github.com/marko-js/cli/blob/master/packages/test/src/util/browser-tests-runner/bundler.js#L44-L51) to the bundler
3. Grabbing the [`window.__coverage__` variable](https://github.com/marko-js/cli/blob/72a05034dae808926d89f147af09a73893232dee/packages/test/src/util/browser-tests-runner/browser-dependencies/index.js#L79) 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`](https://github.com/istanbuljs/babel-plugin-istanbul#source-maps) so the sourcemaps output by Parcel could be passed along.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.