剧作家:如何从电子渲染过程中获得覆盖
我正在重写电子应用程序的测试,使用“@playwright/test”测试运行器,用基于剧作家的测试替换基于 Spectron/mocha 的测试。
剧作家测试正在工作,但我在从电子渲染过程中获取任何覆盖数据时遇到问题。
在 Spectron 情况下,我必须在“卸载”事件上保存渲染过程中的覆盖数据(并且我得到了所有内容),但在剧作家环境中完成类似的操作时遇到问题。
似乎剧作家 startJSCoverage()/stopJSCoverage() API 可能相关,但虽然收集了一些数据,但它似乎来自主进程。
已尝试设置 NODE_V8_COVERAGE=.nyc_output,并且似乎不会影响渲染过程。
从电子渲染过程中收集覆盖率数据的推荐方法是什么?
下面是挽救报道失败的尝试的片段。还使用了一个匹配的await window.coverage.startJSCoverage()。
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));
}
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));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论