操纵J开玩笑-错误:评估失败:ReferenceError:_toConsumableArray2未定义

时间:2020-03-23 15:43:32

标签: javascript automation jestjs puppeteer

在一个演示项目中,我编写了相同的脚本,并且可以从那里完美地工作。但是在我的主项目中,当我粘贴相同的脚本时,尽管设置文件(Error: Evaluation failed: ReferenceError: _toConsumableArray2 is not definedjest.config.jsonjest.setup.js相同,但它却给了我jest-puppeteer-config.js

这是测试用例,

 test("It should click on start button", async () => {
    try {
      const rows = await page.evaluate(
        () => [...document.querySelectorAll(".instances__action")].length
      );

      const buttonSelector = `td:nth-child(7) .ant-btn-primary`;
      const spanSelector = `td:nth-child(3) > span`;

      for (let i = 0; i < rows; i++) {
        const row = `tr:nth-child(${i + 1})`;

        const btnDom = `${row} > ${buttonSelector}`;
        const statusDom = `${row} > ${spanSelector}`;

        await page.$eval(btnDom, element => element.click());

        const currentStatus = await page.evaluate(
          status => document.querySelector(status).innerHTML,
          statusDom
        );

        if (currentStatus === "finished") {
          // It's already finished, so need to wait for changing the status
          await page.waitForFunction(
            status => document.querySelector(status).innerHTML !== "finished",
            {},
            statusDom
          );
        }
        await page.waitForFunction(
          status => document.querySelector(status).innerHTML === "finished",
          {},
          statusDom
        );
      }
    } catch (e) {
      console.log(e);
    }
  });

我在这里想念的是什么?如果脚本中有任何错误,则不应在我的演示项目中使用它!

0 个答案:

没有答案