DEV Community

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

Posted on

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)