I am rewriting tests for an electron application, replacing spectron/mocha based tests with playwright based tests, using the '@playwright/test' test runner.
The playwright tests are working, but I have problems with getting any coverage data from the electron render process.
In the spectron case I had to save coverage data from render process on the 'unload' event (and I got everything), but I have problems getting something similar done in the playwright environment.
It seems that playwright startJSCoverage()/stopJSCoverage() API might be relevant, but while some data is collected, it appears to be from main process.
Setting NODE_V8_COVERAGE=.nyc_output has been tried, and doesn't appear to affect render process.
What is the recommended way to collect coverage data from electron render process?
Below is a snip of a failing attempt to save coverage. There is a matching await window.coverage.startJSCoverage() in use as well.
const coverage = await window.coverage.stopJSCoverage();
for (const entry of coverage) {
let name = `.nyc_output/cl-${v4()}.json`
console.log('electron.spec', name)
console.dir(entry.functions)
fs.writeFileSync(name, JSON.stringify(entry.functions));
}