[feat] module api for intergrators
See original GitHub issueIm integrating code coverage into Bazel: https://github.com/bazelbuild/rules_nodejs However, rather than reimplementing the internal logic we see in this lib it would be great if there was a public facing API that could be used by downstream integrators.
For this kind of integration the main functionality needed
- gathering coverage (without child process/forking)
- producing machine readable reports (in this case we’re after lcov)
- merging reports between projects that might have overlapping coverage
A code example of the api we’re after might look like this
const c8 = require('c8');
c8.collectCoverage({reporters: ['text-summary', 'lcov']});
jasmine.execute();
const reports = await c8.completeCoverage();
const textSummaryReport = reports.find(r => r.type = 'text-summary');
console.log(textSummaryReport);
cons lcovReport = reports.find(r => r.type = 'lcov');
fs.writeFileSync('to/some/location', lcovReport);
// or maybe merge/process it in some other way
Some important points here:
- The lib should not do any IO
- The lib should not require environment variables to collect coverage
I’d be happy to contribute to this design or implementation if needed. Let me know if this is something we’d like to do with this lib
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:14 (11 by maintainers)
Top Results From Across the Web
v8 Coverage for integrators · Issue #28283 · nodejs/node
[feat] module api for intergrators bcoe/c8#116 ... the title v8 Coverage for intergrators v8 Coverage for integrators on Jun 18, 2019.
Read more >Module integration helpers | Entity API
The entity API provides some useful defaults for integrating with rules and for providing Entity property information.
Read more >Plugins - API Builder v5
Plugins are regular node modules that are included in your API Builder project's package.json file. API Builder detects plugins by searching for installed ......
Read more >Become an API Integrator - Learn Interactively
Application Programmable Interface (API) is a software intermediary that allows two applications ... Module 1. Integrate Auth0 with Java Servlet Application.
Read more >APi Systems Integrators | Western States Fire Protection
APi Systems Integrators is a premier special systems integrator, encompassing five states. Our highly talented engineering staff designs projects from scratch ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I opened up https://github.com/istanbuljs/v8-to-istanbul/issues/33. By using that, and copying some
istanbul-lib-*
code fromReport.js
in this repo, I was able to make it work in Jest 🎉The part I copied from c8:
Not too much. So I don’t think we necessarily need to put any more code in c8 - making
v8-to-istanbul
support not talking to the FS seems to cover it?The
inspector
API abstraction I put together: https://github.com/SimenB/jest/blob/917efc3398577c205f33c1c2f9a1aeabfaad6f7d/packages/jest-coverage/src/index.tsUsage:
Note that this does not at all have to live in Jest, it was just easiest for me when doing this work to have it there. It might live in the istanbul org, maybe?
Results in this:
(this is just
require('typescript')
)@Toxicable @SimenB might be worth moving this feature request to Node.js? could imagine this being possible with a signal, not sure what signal.