Skip to content

Commit

Permalink
chore: upgrade cron to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jan 17, 2025
1 parent 7c0b2fd commit 2a35332
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"release": "release-it"
},
"dependencies": {
"cron": "3.2.1"
"cron": "3.5.0"
},
"devDependencies": {
"@commitlint/cli": "19.6.1",
Expand Down Expand Up @@ -50,8 +50,8 @@
"typescript-eslint": "8.20.0"
},
"peerDependencies": {
"@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
"@nestjs/core": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0"
"@nestjs/common": "^10.0.0 || ^11.0.0",
"@nestjs/core": "^10.0.0 || ^11.0.0"
},
"lint-staged": {
"*.ts": [
Expand Down
13 changes: 10 additions & 3 deletions tests/e2e/cron-jobs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,21 @@ describe('Cron', () => {
it(`should catch and log exception inside cron-function added by scheduler`, async () => {
await app.init();
const registry = app.get(SchedulerRegistry);
const errorHandlerSpy = jest.fn();

registry['logger'].error = jest.fn();
const job = new CronJob(CronExpression.EVERY_SECOND, () => {
throw new Error('ERROR IN CRONJOB GOT CATCHED');
const job = CronJob.from({
cronTime: CronExpression.EVERY_SECOND,
onTick: () => {
throw new Error('ERROR IN CRONJOB GOT CATCHED');
},
errorHandler: errorHandlerSpy,
});
registry.addCronJob('THROWS_EXCEPTION_INSIDE', job);
job.start();
clock.tick('1');
expect(registry['logger'].error).toHaveBeenCalledWith(

expect(errorHandlerSpy).toHaveBeenCalledWith(
new Error('ERROR IN CRONJOB GOT CATCHED'),
);
});
Expand Down

0 comments on commit 2a35332

Please sign in to comment.