Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
89
rated 0 times [  92] [ 3]  / answers: 1 / hits: 16685  / 3 Years ago, tue, august 17, 2021, 12:00:00

I want to verify a function that can get update after one minute, and I set some sleep in my code, but my default time out value is 15000 ms, my code has sleep 60000ms so it returns this error:


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."

my code is here:


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);
});

Where should I put jest.setTimeOut()? I want to increase exceeded timeout value to 70000ms to make sure my code runs well.


More From » jestjs

 Answers
32

To set a timeout on a single test, pass a third option to it/test, for example:


 it('testing balabala', async () => {
...
}, 70000);

[#50209] Sunday, July 11, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaleyv

Total Points: 259
Total Questions: 99
Total Answers: 107

Location: Saint Helena
Member since Tue, Nov 3, 2020
4 Years ago
;