Skip to content

Commit 3eeefb9

Browse files
author
pierrezimmermann
committed
refactor: make test faster by decreasing both interval and timeout
1 parent e9f383d commit 3eeefb9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/__tests__/waitFor.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,15 @@ test.each([true, false])(
221221
jest.useFakeTimers({ legacyFakeTimers });
222222

223223
const mockErrorFn = jest.fn(() => {
224-
// Wait 10 seconds so that check time is longer than interval
225-
blockThread(10, legacyFakeTimers);
224+
// Wait 5 seconds so that check time is longer than interval
225+
blockThread(5, legacyFakeTimers);
226226
throw new Error('test');
227227
});
228228

229229
try {
230230
await waitFor(() => mockErrorFn(), {
231-
timeout: 200,
232-
interval: 5,
231+
timeout: 6,
232+
interval: 2,
233233
});
234234
} catch (e) {
235235
// do nothing
@@ -238,7 +238,7 @@ test.each([true, false])(
238238
// Verify that even though time to perform check is longer than interval
239239
// test won't timeout until number of checks * interval >= timeout
240240
// ie fake timers have been advanced by timeout when waitfor rejects
241-
expect(mockErrorFn).toHaveBeenCalledTimes(41);
241+
expect(mockErrorFn).toHaveBeenCalledTimes(4);
242242
}
243243
);
244244

0 commit comments

Comments
 (0)