有一个基于Puppeteer和Jest的小型测试套件,我无法摆脱以下问题
× test page header logo (5019ms)
● test page header logo
Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.
at node_modules/jest-jasmine2/build/queue_runner.js:72:21
at Timeout.callback [as _onTimeout] (node_modules/jsdom/lib/jsdom/browser/Window.js:633:19)
test("test page header logo", async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto("localhost:3000"); // our react app;
const text = await page.$eval("a.brand-logo", (el) => el.innerHTML);
expect(text).toEqual("Logo");
});
答案 0 :(得分:0)
您应该done
test("test page header logo", async (done) => {
并在上一个expect expect(text).toEqual("Logo"); done();
之后运行完成功能