Skip to content

Commit d6dd1a7

Browse files
committed
improve dequeue snapshot test reliability
1 parent d7c0f34 commit d6dd1a7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

apps/webapp/test/fairDequeuingStrategy.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,15 @@ describe("FairDequeuingStrategy", () => {
256256
"consumer-1"
257257
);
258258

259+
const tolerance = 0.15;
260+
const withTolerance = (value: number) => value * (1 + tolerance);
261+
259262
const distribute2Duration = performance.now() - startDistribute2;
260263

261264
console.log("Second distribution took", distribute2Duration, "ms");
262265

263266
// Make sure the second call is more than 9 times faster than the first
264-
expect(distribute2Duration).toBeLessThan(distribute1Duration / 9);
267+
expect(distribute2Duration).toBeLessThan(withTolerance(distribute1Duration / 9));
265268

266269
const startDistribute3 = performance.now();
267270

@@ -275,7 +278,7 @@ describe("FairDequeuingStrategy", () => {
275278
console.log("Third distribution took", distribute3Duration, "ms");
276279

277280
// Make sure the third call is more than 4 times the second
278-
expect(distribute3Duration).toBeGreaterThan(distribute2Duration * 4);
281+
expect(withTolerance(distribute3Duration)).toBeGreaterThan(distribute2Duration * 4);
279282
}
280283
);
281284

0 commit comments

Comments
 (0)