我已经建立了一个serverless函数,用于从特定的Web表单中获取Web抓取信息。我正在使用Jest进行单元测试。效果很好。
当我尝试添加代码覆盖率报告时,测试失败并显示以下错误:
Evaluation failed: ReferenceError: cov_lfnoqvwrd is not defined
at msgs (__puppeteer_evaluation_script__:2:35)
at ExecutionContext.evaluateHandle (node_modules/puppeteer/lib/ExecutionContext.js:124:13)
-- ASYNC --
at ExecutionContext.<anonymous> (node_modules/puppeteer/lib/helper.js:144:27)
at ExecutionContext.evaluate (node_modules/puppeteer/lib/ExecutionContext.js:58:31)
at ExecutionContext.<anonymous> (node_modules/puppeteer/lib/helper.js:145:23)
at Frame.evaluate (node_modules/puppeteer/lib/FrameManager.js:439:20)
-- ASYNC --
at Frame.<anonymous> (node_modules/puppeteer/lib/helper.js:144:27)
at Page.evaluate (node_modules/puppeteer/lib/Page.js:736:43)
at Page.<anonymous> (node_modules/puppeteer/lib/helper.js:145:23)
at evaluate (index.js:230:24)
如果我正确理解此跟踪信息,则Jest在生成传递到伪造者的page.evaluate的功能代码的代码覆盖率时会遇到问题。我的理解正确吗?如何解决此问题并使代码覆盖率报告适用于这种逻辑?
谢谢!