Jest无法在Promise中检测到测试

时间:2019-08-03 21:31:37

标签: javascript jestjs

我正在尝试运行此代码,虽然我可以看到测试must run in num browsers loop已被记录,但尽管上面正好显示了该行,但我却没有看到must run in browser prom被记录了

(async () => {
  try {
    jest.setTimeout(300000);
    const NUM_BROWSERS = 2;
    const NUM_PAGES = 3;
    const hrefss = [
    ];
    const browserProms = [];
    for (let i = 0; i < NUM_BROWSERS; i += 1) {
          test('must run in num browsers loop', () => {
            expect(1).toBe(1);
          });
      browserProms.push(
        new Promise(async resBrowser => {
          const browser = await puppeteer.launch();
          console.log('about to run test in promise...')
          test('must run in browser prom', () => {
            expect(1).toBe(1);
          });
          await browser.close();
          resBrowser();
        })
      );
    }
    await Promise.all(browserProms);
  } catch (e) {
    console.error('error in promise >>>>', e);
  }
})();

注释掉第一个测试时,出现此错误:Your test suite must contain at least one test.

0 个答案:

没有答案