Skip to content

Commit e92cd85

Browse files
committed
fix(test): fix timeout check
1 parent 3fe9a6d commit e92cd85

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test/job.test.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -837,14 +837,15 @@ describe('Job', () => {
837837
});
838838

839839
it('runs a one-time job after its lock expires', async () => {
840-
let runCount = 0;
840+
const processorPromise = new Promise(resolve => {
841+
let runCount = 0;
841842

842-
const processorPromise = new Promise(resolve =>
843843
agenda.define(
844844
'lock job',
845845
async _job => {
846846
runCount++;
847847
if (runCount === 1) {
848+
// this should time out
848849
await new Promise(longResolve => setTimeout(longResolve, 1000));
849850
} else {
850851
resolve(runCount);
@@ -853,14 +854,14 @@ describe('Job', () => {
853854
{
854855
lockLifetime: 50
855856
}
856-
)
857-
);
857+
);
858+
});
858859

859860
let errorHasBeenThrown;
860861
agenda.on('error', err => {
861862
errorHasBeenThrown = err;
862863
});
863-
agenda.processEvery(50);
864+
agenda.processEvery(25);
864865
await agenda.start();
865866
agenda.now('lock job', {
866867
i: 1

0 commit comments

Comments
 (0)