Skip to content

Commit

Permalink
test(repeat): fix flaky tests to use processedOn attribute (#2799)
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored Oct 4, 2024
1 parent e758f70 commit 3ed47f5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/test_repeat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,10 +812,10 @@ describe('repeat', function () {
worker.on('completed', async job => {
if (prev && counter === 1) {
expect(prev.timestamp).to.be.lt(job.timestamp);
expect(job.timestamp - prev.timestamp).to.be.gte(100);
expect(job.processedOn! - prev.timestamp).to.be.gte(100);
} else if (prev) {
expect(prev.timestamp).to.be.lt(job.timestamp);
expect(job.timestamp - prev.timestamp).to.be.gte(2000);
expect(job.processedOn! - prev.timestamp).to.be.gte(2000);
}
prev = job;
counter++;
Expand Down Expand Up @@ -875,10 +875,10 @@ describe('repeat', function () {
worker.on('completed', async job => {
if (counter === 1) {
expect(prev.timestamp).to.be.lt(job.timestamp);
expect(job.timestamp - prev.timestamp).to.be.gte(delay);
expect(job.processedOn! - prev.timestamp).to.be.gte(delay);
} else if (prev) {
expect(prev.timestamp).to.be.lt(job.timestamp);
expect(job.timestamp - prev.timestamp).to.be.gte(ONE_DAY);
expect(job.processedOn! - prev.timestamp).to.be.gte(ONE_DAY);
}
prev = job;

Expand Down Expand Up @@ -922,9 +922,9 @@ describe('repeat', function () {
const worker = new Worker(
queueName,
async () => {
if(counter === 0){
if (counter === 0) {
this.clock.tick(6 * ONE_HOUR);
}else {
} else {
this.clock.tick(nextTick);
}
},
Expand Down Expand Up @@ -1011,7 +1011,7 @@ describe('repeat', function () {
try {
if (prev) {
expect(prev.timestamp).to.be.lt(job.timestamp);
expect(job.timestamp - prev.timestamp).to.be.gte(ONE_DAY);
expect(job.processedOn! - prev.timestamp).to.be.gte(ONE_DAY);
}
prev = job;

Expand Down Expand Up @@ -1073,7 +1073,7 @@ describe('repeat', function () {
try {
if (prev) {
expect(prev.timestamp).to.be.lt(job.timestamp);
expect(job.timestamp - prev.timestamp).to.be.gte(ONE_DAY);
expect(job.processedOn! - prev.timestamp).to.be.gte(ONE_DAY);
}
prev = job;

Expand Down Expand Up @@ -1137,7 +1137,7 @@ describe('repeat', function () {
try {
if (prev) {
expect(prev.timestamp).to.be.lt(job.timestamp);
const diff = moment(job.timestamp).diff(
const diff = moment(job.processedOn!).diff(
moment(prev.timestamp),
'months',
true,
Expand Down

0 comments on commit 3ed47f5

Please sign in to comment.