c8 icon indicating copy to clipboard operation
c8 copied to clipboard

Empty code coverage on transpiled JS code

Open gpradeepjain opened this issue 9 months ago • 2 comments

I am inside a folder that has the below structure src/ -> this has *.js and *.js.map test/ -> this has *.js and *.js.map

I run the command [email protected]/node_modules/c8/bin/c8.js --include src//*.js [email protected]/node_modules/mocha/bin/mocha.js test/unit//*.js --verbose

It does the tests but my coverage report says 0

----------|---------|----------|---------|---------|-------------------

File % Stmts % Branch % Funcs % Lines Uncovered Line #s
All files 0 0 0 0
---------- --------- ---------- --------- --------- -------------------

=============================== Coverage summary =============================== Statements : Unknown% ( 0/0 ) Branches : Unknown% ( 0/0 ) Functions : Unknown% ( 0/0 ) Lines : Unknown% ( 0/0 )

I tried --src src as well. But nothing worked. Does C8 work for transpiled JS code? How do I debug the above problem?

gpradeepjain avatar Apr 09 '25 14:04 gpradeepjain

@gpradeepjain could you provide a repository with a minimal reproduction please 👏

bcoe avatar May 01 '25 18:05 bcoe

In my case the coverage showed as empty if I killed the running process with ctrl+C. If I run process.exit(0) to terminate the js script, then everything gets picked up

kuba-orlik avatar Jul 21 '25 18:07 kuba-orlik