Skip to content
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
nicohrubec committed Mar 10, 2026
commit 21ab9a7a3e1d78a40c35f37d75c1c484dce8af8d
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ test('Cron job triggers send of in_progress envelope', async ({ baseURL }) => {

test('Sends exceptions to Sentry on error in cron job', async ({ baseURL }) => {
const errorEventPromise = waitForError('nestjs-11', event => {
return !event.type && event.exception?.values?.[0]?.value === 'Test error from cron job';
return (
!event.type &&
event.exception?.values?.[0]?.value === 'Test error from cron job' &&
event.exception?.values?.[0]?.mechanism?.type === 'auto.schedule.nestjs.cron'
);
});

const errorEvent = await errorEventPromise;
Expand All @@ -73,7 +77,7 @@ test('Sends exceptions to Sentry on error in cron job', async ({ baseURL }) => {
expect(errorEvent.exception?.values?.[0]?.value).toBe('Test error from cron job');
expect(errorEvent.exception?.values?.[0]?.mechanism).toEqual({
handled: false,
type: 'auto.cron.nestjs.async',
type: 'auto.schedule.nestjs.cron',
});

expect(errorEvent.contexts?.trace).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ test('Cron job triggers send of in_progress envelope', async ({ baseURL }) => {

test('Sends exceptions to Sentry on error in cron job', async ({ baseURL }) => {
const errorEventPromise = waitForError('nestjs-fastify', event => {
return !event.type && event.exception?.values?.[0]?.value === 'Test error from cron job';
return (
!event.type &&
event.exception?.values?.[0]?.value === 'Test error from cron job' &&
event.exception?.values?.[0]?.mechanism?.type === 'auto.schedule.nestjs.cron'
);
});

const errorEvent = await errorEventPromise;
Expand All @@ -73,7 +77,7 @@ test('Sends exceptions to Sentry on error in cron job', async ({ baseURL }) => {
expect(errorEvent.exception?.values?.[0]?.value).toBe('Test error from cron job');
expect(errorEvent.exception?.values?.[0]?.mechanism).toEqual({
handled: false,
type: 'auto.cron.nestjs.async',
type: 'auto.schedule.nestjs.cron',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: This would in theory break existing queries – maybe worth calling it out in the changelog

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes definitely. I will also update this to auto.function.nestjs.cron (and similar for the others) to align with the span ops

});
expect(errorEvent.contexts?.trace).toEqual({
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
Expand Down
1 change: 0 additions & 1 deletion packages/nestjs/test/integrations/schedule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,5 @@ describe('ScheduleInstrumentation', () => {

expect(descriptor.value).toBe(originalHandler);
});

});
});
Loading