Skip to content

Commit

Permalink
test(delay): fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Oct 1, 2023
1 parent b2d768e commit 3ffbd17
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/test_delay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ describe('Delayed jobs', function () {
'waited less than delay time and margin',
).to.be.lessThan(delay * margin);
} catch (err) {
console.error(err);
reject(err);
}
if (!numJobs) {
Expand All @@ -306,9 +307,12 @@ describe('Delayed jobs', function () {
);
});

while (numJobs--) {
while (numJobs) {
numJobs -= 1;
await queue.add('my-queue', { foo: 'bar' }, { delay });
await new Promise(r => setTimeout(r, 300));
if (numJobs) {
await new Promise(resolve => setTimeout(resolve, 300));
}
}

await processing;
Expand Down

0 comments on commit 3ffbd17

Please sign in to comment.