diff --git a/packages/node/src/cron/cron.ts b/packages/node/src/cron/cron.ts index 2540d82e736b..8b6fc324a7a6 100644 --- a/packages/node/src/cron/cron.ts +++ b/packages/node/src/cron/cron.ts @@ -100,7 +100,7 @@ export function instrumentCron(lib: T & CronJobConstructor, monitorSlug: stri }, { schedule: { type: 'crontab', value: cronString }, - ...(timeZone ? { timeZone } : {}), + timezone: timeZone || undefined, }, ); } @@ -132,7 +132,7 @@ export function instrumentCron(lib: T & CronJobConstructor, monitorSlug: stri }, { schedule: { type: 'crontab', value: cronString }, - ...(timeZone ? { timeZone } : {}), + timezone: timeZone || undefined, }, ); }; diff --git a/packages/node/test/cron.test.ts b/packages/node/test/cron.test.ts index eee6d4a66711..d068280a41e0 100644 --- a/packages/node/test/cron.test.ts +++ b/packages/node/test/cron.test.ts @@ -53,13 +53,20 @@ describe('cron check-ins', () => { const CronJobWithCheckIn = cron.instrumentCron(CronJobMock, 'my-cron-job'); - new CronJobWithCheckIn('* * * Jan,Sep Sun', () => { - expect(withMonitorSpy).toHaveBeenCalledTimes(1); - expect(withMonitorSpy).toHaveBeenLastCalledWith('my-cron-job', expect.anything(), { - schedule: { type: 'crontab', value: '* * * 1,9 0' }, - }); - done(); - }); + new CronJobWithCheckIn( + '* * * Jan,Sep Sun', + () => { + expect(withMonitorSpy).toHaveBeenCalledTimes(1); + expect(withMonitorSpy).toHaveBeenLastCalledWith('my-cron-job', expect.anything(), { + schedule: { type: 'crontab', value: '* * * 1,9 0' }, + timezone: 'America/Los_Angeles', + }); + done(); + }, + undefined, + true, + 'America/Los_Angeles', + ); }); test('CronJob.from()', done => {