Skip to content

Commit e6471fe

Browse files
author
pierrezimmermann
committed
refactor: expect waitFor to throw rather than wrapping in try catch
1 parent 3eeefb9 commit e6471fe

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Diff for: src/__tests__/waitFor.test.tsx

+7-8
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,13 @@ test.each([true, false])(
226226
throw new Error('test');
227227
});
228228

229-
try {
230-
await waitFor(() => mockErrorFn(), {
231-
timeout: 6,
232-
interval: 2,
233-
});
234-
} catch (e) {
235-
// do nothing
236-
}
229+
await expect(
230+
async () =>
231+
await waitFor(() => mockErrorFn(), {
232+
timeout: 6,
233+
interval: 2,
234+
})
235+
).rejects.toThrow();
237236

238237
// Verify that even though time to perform check is longer than interval
239238
// test won't timeout until number of checks * interval >= timeout

0 commit comments

Comments
 (0)