Fixed non-deterministic tests

This commit is contained in:
Kir_Antipov 2022-07-04 20:45:41 +03:00
parent 235aa3c252
commit a1dea07776

View file

@ -27,7 +27,7 @@ describe("retry", () => {
expect(await retry({ func: createThrowingFunc(2), maxAttempts: 2, delay: 100 })).toBe(true); expect(await retry({ func: createThrowingFunc(2), maxAttempts: 2, delay: 100 })).toBe(true);
const end = new Date(); const end = new Date();
const duration = end.getTime() - start.getTime(); const duration = end.getTime() - start.getTime();
expect(duration >= 100 && duration < 200).toBe(true); expect(duration > 50 && duration < 200).toBe(true);
}); });
test("the original error is thrown if retry function didn't succeed", async () => { test("the original error is thrown if retry function didn't succeed", async () => {
@ -53,7 +53,7 @@ describe("retry (async)", () => {
expect(await retry({ func: createAsyncThrowingFunc(2), maxAttempts: 2, delay: 100 })).toBe(true); expect(await retry({ func: createAsyncThrowingFunc(2), maxAttempts: 2, delay: 100 })).toBe(true);
const end = new Date(); const end = new Date();
const duration = end.getTime() - start.getTime(); const duration = end.getTime() - start.getTime();
expect(duration >= 100 && duration < 200).toBe(true); expect(duration > 50 && duration < 200).toBe(true);
}); });
test("the original error is thrown if retry function didn't succeed", async () => { test("the original error is thrown if retry function didn't succeed", async () => {