Skip to content

Commit

Permalink
more deprecations with toThrowError
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Oct 28, 2024
1 parent 4af2c5a commit 66f4701
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/astro/test/server/middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('sentryMiddleware', () => {
});

// @ts-expect-error, a partial ctx object is fine here
await expect(async () => middleware(ctx, next)).rejects.toThrowError();
await expect(async () => middleware(ctx, next)).rejects.toThrow();

expect(captureExceptionSpy).toHaveBeenCalledWith(error, {
mechanism: { handled: false, type: 'astro', data: { function: 'astroMiddleware' } },
Expand Down
2 changes: 1 addition & 1 deletion packages/cloudflare/test/transport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('IsolatedPromiseBuffer', () => {
await ipb.add(task2);
await ipb.add(task3);

await expect(ipb.add(task4)).rejects.toThrowError('Not adding Promise because buffer limit was reached.');
await expect(ipb.add(task4)).rejects.toThrow('Not adding Promise because buffer limit was reached.');
});

it('should not throw when one of the tasks throws when drained', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('wrapCloudEventFunction', () => {
});

const wrappedHandler = wrapCloudEventFunction(handler);
await expect(handleCloudEvent(wrappedHandler)).rejects.toThrowError(error);
await expect(handleCloudEvent(wrappedHandler)).rejects.toThrow(error);

const fakeTransactionContext = {
name: 'event.type',
Expand All @@ -143,7 +143,7 @@ describe('wrapCloudEventFunction', () => {
throw error;
};
const wrappedHandler = wrapCloudEventFunction(handler);
await expect(handleCloudEvent(wrappedHandler)).rejects.toThrowError(error);
await expect(handleCloudEvent(wrappedHandler)).rejects.toThrow(error);

const fakeTransactionContext = {
name: 'event.type',
Expand Down Expand Up @@ -189,7 +189,7 @@ describe('wrapCloudEventFunction', () => {
cb(error);
};
const wrappedHandler = wrapCloudEventFunction(handler);
await expect(handleCloudEvent(wrappedHandler)).rejects.toThrowError(error);
await expect(handleCloudEvent(wrappedHandler)).rejects.toThrow(error);

const fakeTransactionContext = {
name: 'event.type',
Expand All @@ -212,7 +212,7 @@ describe('wrapCloudEventFunction', () => {
throw error;
};
const wrappedHandler = wrapCloudEventFunction(handler);
await expect(handleCloudEvent(wrappedHandler)).rejects.toThrowError(error);
await expect(handleCloudEvent(wrappedHandler)).rejects.toThrow(error);

const fakeTransactionContext = {
name: 'event.type',
Expand Down
10 changes: 5 additions & 5 deletions packages/google-cloud-serverless/test/gcpfunction/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('wrapEventFunction', () => {
throw error;
};
const wrappedHandler = wrapEventFunction(handler);
await expect(handleEvent(wrappedHandler)).rejects.toThrowError(error);
await expect(handleEvent(wrappedHandler)).rejects.toThrow(error);

const fakeTransactionContext = {
name: 'event.type',
Expand Down Expand Up @@ -145,7 +145,7 @@ describe('wrapEventFunction', () => {
});

const wrappedHandler = wrapEventFunction(handler);
await expect(handleEvent(wrappedHandler)).rejects.toThrowError(error);
await expect(handleEvent(wrappedHandler)).rejects.toThrow(error);

const fakeTransactionContext = {
name: 'event.type',
Expand Down Expand Up @@ -191,7 +191,7 @@ describe('wrapEventFunction', () => {
cb(error);
};
const wrappedHandler = wrapEventFunction(handler);
await expect(handleEvent(wrappedHandler)).rejects.toThrowError(error);
await expect(handleEvent(wrappedHandler)).rejects.toThrow(error);

const fakeTransactionContext = {
name: 'event.type',
Expand All @@ -214,7 +214,7 @@ describe('wrapEventFunction', () => {
throw error;
};
const wrappedHandler = wrapEventFunction(handler);
await expect(handleEvent(wrappedHandler)).rejects.toThrowError(error);
await expect(handleEvent(wrappedHandler)).rejects.toThrow(error);

const fakeTransactionContext = {
name: 'event.type',
Expand All @@ -236,7 +236,7 @@ describe('wrapEventFunction', () => {
throw error;
};
const wrappedHandler = wrapEventFunction(handler);
await expect(handleEvent(wrappedHandler)).rejects.toThrowError(error);
await expect(handleEvent(wrappedHandler)).rejects.toThrow(error);

expect(mockCaptureException).toHaveBeenCalledWith(error, expect.any(Function));

Expand Down
8 changes: 4 additions & 4 deletions packages/node/test/cron.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('cron check-ins', () => {
//
},
});
}).toThrowError("A job named 'my-cron-job' has already been scheduled");
}).toThrow("A job named 'my-cron-job' has already been scheduled");
});
});

Expand Down Expand Up @@ -149,7 +149,7 @@ describe('cron check-ins', () => {
cronWithCheckIn.schedule('* * * * *', () => {
//
});
}).toThrowError('Missing "name" for scheduled job. A name is required for Sentry check-in monitoring.');
}).toThrow('Missing "name" for scheduled job. A name is required for Sentry check-in monitoring.');
});
});

Expand Down Expand Up @@ -194,7 +194,7 @@ describe('cron check-ins', () => {
scheduleWithCheckIn.scheduleJob('my-cron-job', new Date(), () => {
//
});
}).toThrowError(
}).toThrow(
"Automatic instrumentation of 'node-schedule' requires the first parameter of 'scheduleJob' to be a job name string and the second parameter to be a crontab string",
);
});
Expand All @@ -212,7 +212,7 @@ describe('cron check-ins', () => {
scheduleWithCheckIn.scheduleJob('* * * * *', () => {
//
});
}).toThrowError(
}).toThrow(
"Automatic instrumentation of 'node-schedule' requires the first parameter of 'scheduleJob' to be a job name string and the second parameter to be a crontab string",
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Unit | eventBuffer | EventBufferArray', () => {
await buffer.addEvent(largeEvent);

// Now it should error
await expect(() => buffer.addEvent(largeEvent)).rejects.toThrowError(EventBufferSizeExceededError);
await expect(() => buffer.addEvent(largeEvent)).rejects.toThrow(EventBufferSizeExceededError);
});

it('resets size limit on clear', async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('Unit | eventBuffer | EventBufferCompressionWorker', () => {
await buffer.addEvent(largeEvent);

// Now it should error
await expect(() => buffer.addEvent(largeEvent)).rejects.toThrowError(EventBufferSizeExceededError);
await expect(() => buffer.addEvent(largeEvent)).rejects.toThrow(EventBufferSizeExceededError);
});

it('resets size limit on clear', async function () {
Expand Down
2 changes: 1 addition & 1 deletion packages/sveltekit/test/server/serverRoute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('wrapServerRouteWithSentry', () => {

await expect(async () => {
await wrappedRouteHandler(getRequestEventMock() as RequestEvent);
}).rejects.toThrowError('Server Route Error');
}).rejects.toThrow('Server Route Error');

expect(captureExceptionSpy).toHaveBeenCalledWith(error, {
mechanism: { type: 'sveltekit', handled: false, data: { function: 'serverRoute' } },
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/test/promisebuffer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('PromiseBuffer', () => {
});
const producer2 = jest.fn(() => new SyncPromise(resolve => setTimeout(resolve)));
expect(buffer.add(producer1)).toEqual(task1);
void expect(buffer.add(producer2)).rejects.toThrowError();
void expect(buffer.add(producer2)).rejects.toThrow();
expect(buffer.$.length).toEqual(1);
expect(producer1).toHaveBeenCalled();
expect(producer2).not.toHaveBeenCalled();
Expand Down
2 changes: 1 addition & 1 deletion packages/vercel-edge/test/transports/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('IsolatedPromiseBuffer', () => {
await ipb.add(task2);
await ipb.add(task3);

await expect(ipb.add(task4)).rejects.toThrowError('Not adding Promise because buffer limit was reached.');
await expect(ipb.add(task4)).rejects.toThrow('Not adding Promise because buffer limit was reached.');
});

it('should not throw when one of the tasks throws when drained', async () => {
Expand Down

0 comments on commit 66f4701

Please sign in to comment.