Merge the results of different testing tools and report it (Read report from lcov.info instead of json files)
- Dominant language
- JavaScript
- Stars
- 2.1k
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
* **Version**: v18.16.0
* **Platform**: Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64 x86_64 GNU/Linux
* **c8 Version**: 8.0.0
I'm working on a project where we use two different testing tools - **mocha** for node tests, and **web-test-runner** for tests on the browser.
While setting up **c8**, I could easily set it up to report for the node tests, by simply having a script like:
`"test:coverage": "c8 mocha"`
Our browser tests script, on the other hand, is called as:
`"test:browser": "npx web-test-runner 'src/spec/browser/**/*.spec.ts' --playwright --browsers chromium firefox"`
Now what I want to do is to have a report that shows the coverage of both the browser and node tests together. From what I've found, c8 doesn't really have an option to merge the results.
The solution I came up with is to use the `--coverage` option with the `"test:browser"` script, and by using the following config in my `web-test-runner.config.mjs`:
```javascript
coverageConfig: {
report: true,
reporters: ['lcovonly', 'text', 'text-summary'],
reportDir: './coverage/browser'
}
```
I then have my `.c8rc` as:
```javascript
{
"all": true,
"include": ["src/lib/**/*.ts"],
"exclude": ["src/spec/**/*.ts", "src/typings/*.ts", "src/lib/index.ts"],
"reporter": ["lcovonly", "text", "text-summary"],
"check-coverage": true,
"clean": true,
"reports-dir": "./coverage/node"
}
```
That way both testing tools generate their own `lcov.info` file in their respective folders. Then with the help of the `lcov` lib I can manage to merge that, but then I'd like to somehow make usage of the `c8 report` command to output the result on the console.
By manually placing the merged `lcov.info` file into the `coverage/node` folder and running the `c8 report` command, I realized the results didn't change, regardless of the changes in the file, since the `report` command reads from json files located in the `/tmp` folder.
So my question is: Is there any way to achieve what I want? To use `c8` to report text (on console) a merged result coming from another test runner?
Thanks in advance.
Contributor guide
Assessment
This issue has not been assessed yet.