DEV Community

Cover image for C8 a native V8 code-coverage
Marcos Henrique
Marcos Henrique

Posted on

11 2

C8 a native V8 code-coverage

Originally created by Benjamin E. Coe one of the maintainers of istanbul, is based on code-coverage using Node.js' built in functionality that's compatible with Istanbul's reporters, with 100k of downloads on npm, it's an awesome alternative for the most popular command line tool for instrumenting code coverage nyc.

Like nyc, c8 just magically works:



yarn global add c8
c8 node xpto.js


Enter fullscreen mode Exit fullscreen mode

But why did you use this c8 instead of nyc? 🀨

First of all i will clarify about my motivation πŸ€”

I've been working on a project in node.js, using mocha and chai for the tests, this project uses esm and because of this I had some problems with nyc, he couldn't identify the files and raise the coverage of each one, I followed what the community recommended and nothing, my tech lead (a.k.a mister Snack) suggested refactoring all import a from 'a' to const a = require('a'), however, I didn't want to have all this work πŸ˜…

So I looked for some alternative and discovered the c8, that I could generate the reporters in the same way as I would with nyc, and because it is based on V8's built in coverage

It's a great tool, and here's the tip if you want to try a new technology.

You can see more about c8 here.

GitHub logo bcoe / c8

output coverage reports using Node.js' built in coverage



🍻

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❀️