• <bdo id='55NUC'></bdo><ul id='55NUC'></ul>

      <i id='55NUC'><tr id='55NUC'><dt id='55NUC'><q id='55NUC'><span id='55NUC'><b id='55NUC'><form id='55NUC'><ins id='55NUC'></ins><ul id='55NUC'></ul><sub id='55NUC'></sub></form><legend id='55NUC'></legend><bdo id='55NUC'><pre id='55NUC'><center id='55NUC'></center></pre></bdo></b><th id='55NUC'></th></span></q></dt></tr></i><div id='55NUC'><tfoot id='55NUC'></tfoot><dl id='55NUC'><fieldset id='55NUC'></fieldset></dl></div>
      1. <tfoot id='55NUC'></tfoot><legend id='55NUC'><style id='55NUC'><dir id='55NUC'><q id='55NUC'></q></dir></style></legend>

        <small id='55NUC'></small><noframes id='55NUC'>

        将 Jest 与 Puppeteer 一起使用:评估失败:ReferenceErr

        时间:2023-09-06

        <small id='Ov5eP'></small><noframes id='Ov5eP'>

          <tbody id='Ov5eP'></tbody>
            <bdo id='Ov5eP'></bdo><ul id='Ov5eP'></ul>

            1. <tfoot id='Ov5eP'></tfoot>

              • <legend id='Ov5eP'><style id='Ov5eP'><dir id='Ov5eP'><q id='Ov5eP'></q></dir></style></legend>

                1. <i id='Ov5eP'><tr id='Ov5eP'><dt id='Ov5eP'><q id='Ov5eP'><span id='Ov5eP'><b id='Ov5eP'><form id='Ov5eP'><ins id='Ov5eP'></ins><ul id='Ov5eP'></ul><sub id='Ov5eP'></sub></form><legend id='Ov5eP'></legend><bdo id='Ov5eP'><pre id='Ov5eP'><center id='Ov5eP'></center></pre></bdo></b><th id='Ov5eP'></th></span></q></dt></tr></i><div id='Ov5eP'><tfoot id='Ov5eP'></tfoot><dl id='Ov5eP'><fieldset id='Ov5eP'></fieldset></dl></div>
                  本文介绍了将 Jest 与 Puppeteer 一起使用:评估失败:ReferenceError: cov_4kq3tptqc is not defined的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试使用 Puppeteer 获取页面的描述,我有一个高阶函数,为该函数提供页面对象:

                  I'm trying to get description of a page with Puppeteer, I have a high order function that provides the page object to this function :

                  export const checkDescription = async page => {
                    const metaDescription = await page.$eval(
                      'meta[name="description"]',
                      description => description.getAttribute("content")
                    );
                    return metaDescription;
                  };
                  

                  该功能按预期工作.然后,我正在使用 Jest 运行测试.

                  the function works as expected. Then, I'm using Jest to run a test.

                  const testDescription = await withPage(checkDescription)(URL);
                  expect(typeof testDescription).toBe("string");
                  

                  我有以下错误:

                    Error: Evaluation failed: ReferenceError: cov_4kq3tptqc is not defined
                        at __puppeteer_evaluation_script__:2:41
                        at ExecutionContext.evaluateHandle 
                        at <anonymous>
                        at process._tickCallback (internal/process/next_tick.js:188:7)
                      -- ASYNC --
                        at ExecutionContext.<anonymous> 
                        at ExecutionContext.evaluate
                        at ExecutionContext.<anonymous> 
                        at ElementHandle.$eval
                        at <anonymous>
                        at process._tickCallback (internal/process/next_tick.js:188:7)
                      -- ASYNC --
                  

                  如果我只是将函数粘贴到 jest 文件中,那么它会按预期工作

                  If I just paste the function in the jest file, then it works as expected

                  推荐答案

                  如果需要收集覆盖率,可以通过在浏览器上下文函数前添加 /* istanbul ignore next */ 来修复(带有 .eval) 的行以防止伊斯坦布尔覆盖注入.

                  If you need to collect the coverage, it can be fixed by adding /* istanbul ignore next */ before browser contexted functions (lines with .eval) to prevent istanbul coverage injects.

                  这篇关于将 Jest 与 Puppeteer 一起使用:评估失败:ReferenceError: cov_4kq3tptqc is not defined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Selenium:无法理解 xPath 下一篇:Testcafe 从元素中获取文本

                  相关文章

                  最新文章

                2. <small id='1nso1'></small><noframes id='1nso1'>

                3. <i id='1nso1'><tr id='1nso1'><dt id='1nso1'><q id='1nso1'><span id='1nso1'><b id='1nso1'><form id='1nso1'><ins id='1nso1'></ins><ul id='1nso1'></ul><sub id='1nso1'></sub></form><legend id='1nso1'></legend><bdo id='1nso1'><pre id='1nso1'><center id='1nso1'></center></pre></bdo></b><th id='1nso1'></th></span></q></dt></tr></i><div id='1nso1'><tfoot id='1nso1'></tfoot><dl id='1nso1'><fieldset id='1nso1'></fieldset></dl></div>

                      • <bdo id='1nso1'></bdo><ul id='1nso1'></ul>
                      <legend id='1nso1'><style id='1nso1'><dir id='1nso1'><q id='1nso1'></q></dir></style></legend>

                      <tfoot id='1nso1'></tfoot>