bcoe / c8

output coverage reports using Node.js' built in coverage
ISC License
1.98k stars 89 forks source link

C8 is not working with electron #309

Open Ramanujam1983 opened 3 years ago

Ramanujam1983 commented 3 years ago

Node Version: v10.19 Platform: Ubuntu 20.04

I am trying to run C8 code coverage for electron.js which is also dependent on node.js and chromium v8. I am trying to do the following: c8 electron . OR c8 npm start

Upon closing the electron application, c8 was suppose to give code coverage report. it is not giving any report. How do we generate code coverage report by using c8 with electron?

bcoe commented 2 years ago

Hello @Ramanujam1983, to make c8 work with electron, you would need to configure Node.js to output coverage reports, by setting NODE_V8_COVERAGE. Similarly, you can get coverage reports from the inspector in the Chromium instance.

c8 can be used to print coverage reports, based on these outputs, but using c8 to run an electron application won't work out of the box.

mox17 commented 2 years ago

Hello, I am trying to get coverage from an electron application using c8 with playwright and @playwright/test. I have set NODE_V8_COVERAGE to the desired output directory and run the test as this:

c8 --reporter=html playwright test --workers=1

When I run this I get some coverage, but only from the main process, i.e. nothing from the render process.

Are there additional steps needed to make the electron render process also save coverage?

versions: chrome: "100.0.4896.75" electron: "18.0.4" node: "16.13.2" v8: "10.0.139.9-electron.0"

c8: "7.11.0"