Run integration tests against the real BullMQ driver (#22551)
Migrate whole suite to real BullMQ Shard times unchanged, still 5-6 min.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
type ExpectEventuallyOptions = {
|
||||
timeoutMs?: number;
|
||||
intervalMs?: number;
|
||||
};
|
||||
|
||||
export const expectEventually = async (
|
||||
assertion: () => Promise<void> | void,
|
||||
{ timeoutMs = 10_000, intervalMs = 100 }: ExpectEventuallyOptions = {},
|
||||
): Promise<void> => {
|
||||
const startedAt = Date.now();
|
||||
|
||||
for (;;) {
|
||||
try {
|
||||
await assertion();
|
||||
|
||||
return;
|
||||
} catch (error) {
|
||||
if (Date.now() - startedAt > timeoutMs) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user