Skip to content

Commit 4ce4934

Browse files
authored
fix flaky test (#606)
Co-authored-by: Seth Silesky <silesky@users.noreply.github.com>
1 parent deadc7c commit 4ce4934

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/core/src/analytics/__tests__/dispatch.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,15 @@ describe(getDelay, () => {
115115
it('should calculate the amount of time to delay before invoking the callback', () => {
116116
const aShortTimeAgo = Date.now() - 200
117117
const timeout = 5000
118-
expect(Math.round(getDelay(aShortTimeAgo, timeout))).toBe(4800)
118+
const result = getDelay(aShortTimeAgo, timeout)
119+
expect(result).toBeLessThanOrEqual(4800)
120+
expect(result).toBeGreaterThanOrEqual(4790)
119121
})
120122

121123
it('should have a sensible default', () => {
122124
const aShortTimeAgo = Date.now() - 200
123-
expect(Math.round(getDelay(aShortTimeAgo))).toBe(100)
125+
const result = getDelay(aShortTimeAgo)
126+
expect(result).toBeLessThanOrEqual(100)
127+
expect(result).toBeGreaterThanOrEqual(90)
124128
})
125129
})

0 commit comments

Comments
 (0)