我想验证一个可以在一分钟后更新的函数,并且我在代码中设置了一些睡眠,但我的默认超时值是 15000 毫秒,我的代码有睡眠 60000 毫秒,所以它返回此错误:
thrown: "Exceeded timeout of 15000 ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value,
if this is a long-running test."
Run Code Online (Sandbox Code Playgroud)
我的代码在这里:
it('shows that timeline can get updated after one minute', async () => {
await selectTimeForTimeLine.selectTime('Last 5 minutes');
await page.waitForTimeout(3000);
const defaultTime = await alarmTimeLine.xAxisValues();
await page.evaluate(() => {
return new Promise((resolve) => setTimeout(resolve, 60000));
});
const correntTime = await alarmTimeLine.xAxisValues();
expect(defaultTime).not.toEqual(correntTime);
});
Run Code Online (Sandbox Code Playgroud)
我应该放在哪里jest.setTimeOut()
?我想将超出的超时值增加到 70000 毫秒,以确保我的代码运行良好。