-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for deleting chat messages, use HTTP endpoints for mute test (
#665) * Use mute endpoint in chat test * order * reduce interval * Add tests for deleting messages * use retryFor in booth vote test too * factor out retry, i guess
- Loading branch information
1 parent
b882eb2
commit 4ec71f3
Showing
3 changed files
with
210 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import delay from 'delay'; | ||
|
||
/** Retry the `fn` until it doesn't throw, or until the duration in milliseconds has elapsed. */ | ||
export async function retryFor(duration, fn) { | ||
const end = Date.now() + duration; | ||
let caughtError; | ||
while (Date.now() < end) { | ||
try { | ||
const result = await fn(); | ||
return result; | ||
} catch (err) { | ||
caughtError = err; | ||
} | ||
await delay(10); | ||
} | ||
|
||
if (caughtError != null) { | ||
throw new Error(`Failed after ${duration}ms`, { cause: caughtError }); | ||
} | ||
} |