bcoe / bcoe/c8

Accept coverage info, collected from the browser

Open
#339 12 comments 4 reactions 0 assignees View on GitHub
feature-request
Dominant language
JavaScript
Stars
2.1k
Forks
99
PR merge metrics
No merged PRs in 30d

Description

I'm developing a cross-platform testing tool, which can run tests in browsers, Node and Deno: https://siesta.works

I'm trying to promote `c8` as a recommended code coverage tool for it. It seems to work well for the Node.js tests.

However, if I collect coverage objects from the Chromium web pages, `c8` does not recognize them as such. This is because Chromium's coverage object seems to have different format from Node's.

Node's format:
```
{
"result": [{
"scriptId": "7",
"url": "file:///home/nickolay/workspace/siesta-workspace/siesta-monorepo/packages/siesta/bin/siesta.js",
...
}],
"source-map-cache": {
"file:///home/nickolay/workspace/siesta-workspace/siesta-monorepo/node_modules/.pnpm/@web+dev-server@0.1.24_rollup@2.58.0/node_modules/@web/dev-server/dist/index.js": {
"lineLengths": [13, 62, 137, 51, 133, 54, 127, 61, 148, 57, 130, 65, 142, 33],
},
```
Chromium's format:
```
[
{
"scriptId": "32",
"url": "http://localhost:8000/browser.js",
...
"source": "..."
}
]
```
So browser's format includes "raw" sources and does not contain the `results` property. Data from browser is collected with Playwright: https://playwright.dev/docs/api/class-coverage

I'm willing to contribute a PR normalizing this format difference when generating a report, would you accept it and may be provide some guidance?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.