nyc
nyc copied to clipboard
How to instrument code for Electron app?
Hi,
I am very sorry if this is actually not a bug, but I don't know any support channel and I am lost on this at the moment.
I wrote an Electron app, and setup a few tests with ava
which start my app, trigger a few functions and terminate the application. nyc
put on top only covers the executions from the Main Process.
As far as I understand, this is caused because nyc
doesn't reach down to the browser context. Is there any way to build my entire Electron application with instrumented code, so I can still create a coverage report?
Here are a few snippets from my package.json
:
"scripts": {
"build": "npm run electron:serve-tsc && ng build --base-href ./",
"ava-ts": "env NODE_ENV=ava ava-ts --serial",
},
"ava-ts": {
"cache": false,
"serial": true,
"verbose": true,
"timeout": 10000,
"instrument": true
},
Any help is highly appreciated! Thank you!
Hi, is there any chance for support on this? Any help is appreciated! Thank you!
You likely need to use babel-plugin-istanbul, though I don't have any specific instructions for doing this in electron or under ava-ts. This is a somewhat advanced topic which I don't have the knowledge to support.
@MMcKester, I wrote an article on how to setup TypeScript code coverage for Electron applications. Hope it helps you! 🍀