Testing 让木偶演员等待全球设置完成

Testing 让木偶演员等待全球设置完成,testing,jestjs,puppeteer,jest-puppeteer,Testing,Jestjs,Puppeteer,Jest Puppeteer,我使用Jest Puppeter结束Web应用程序的测试。所有测试都与异步函数并行运行。现在我发现第一个测试在globalSetup完成和数据准备工作完成(初始化客户端设置等)之前就已经运行了 我尝试在请求后超时,但这不起作用,因为现在所有请求都有一个超时 import puppeteer from "puppeteer"; import { getUrlByPath, post } from "../helper"; module.exports = async function glob

我使用Jest Puppeter结束Web应用程序的测试。所有测试都与异步函数并行运行。现在我发现第一个测试在globalSetup完成和数据准备工作完成(初始化客户端设置等)之前就已经运行了

我尝试在请求后超时,但这不起作用,因为现在所有请求都有一个超时

import puppeteer from "puppeteer";

import { getUrlByPath, post } from "../helper";

module.exports = async function globalSetup(globalConfig) {
  await setupPuppeteer(globalConfig);

  puppeteer.launch({args: ["--no-sandbox", "--disable-setuid-sandbox"]}).then(async browser => {
    const page = await browser.newPage();

    await post(
      page,
      getUrlByPath("somePath"),
      "prepare_data_for_testing",
    );

    await browser.close();
  });
};
上面的代码运行一个globalConfig,然后开始为测试环境准备数据


有没有办法让测试套件在这个脚本返回带有
http200:ok
的帖子后运行?

我必须在
puppeter之前放置
wait
。启动
并添加
require(“expect puppeter”)在顶部