diff --git a/packages/node-integration-tests/suites/public-api/captureException/catched-error/scenario.ts b/packages/node-integration-tests/suites/public-api/captureException/catched-error/scenario.ts new file mode 100644 index 000000000000..0318461ab9c7 --- /dev/null +++ b/packages/node-integration-tests/suites/public-api/captureException/catched-error/scenario.ts @@ -0,0 +1,12 @@ +import * as Sentry from '@sentry/node'; + +Sentry.init({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + release: '1.0', +}); + +try { + throw new Error('catched_error'); +} catch (err) { + Sentry.captureException(err); +} diff --git a/packages/node-integration-tests/suites/public-api/captureException/catched-error/test.ts b/packages/node-integration-tests/suites/public-api/captureException/catched-error/test.ts new file mode 100644 index 000000000000..f6fee1d8b819 --- /dev/null +++ b/packages/node-integration-tests/suites/public-api/captureException/catched-error/test.ts @@ -0,0 +1,24 @@ +import { assertSentryEvent, getEventRequest, runServer } from '../../../../utils'; + +test('should work inside catch block', async () => { + const url = await runServer(__dirname); + const requestBody = await getEventRequest(url); + + assertSentryEvent(requestBody, { + exception: { + values: [ + { + type: 'Error', + value: 'catched_error', + mechanism: { + type: 'generic', + handled: true, + }, + stacktrace: { + frames: expect.any(Array), + }, + }, + ], + }, + }); +}); diff --git a/packages/node-integration-tests/suites/public-api/capture-exception/scenario.ts b/packages/node-integration-tests/suites/public-api/captureException/empty-obj/scenario.ts similarity index 70% rename from packages/node-integration-tests/suites/public-api/capture-exception/scenario.ts rename to packages/node-integration-tests/suites/public-api/captureException/empty-obj/scenario.ts index b2a41905210c..87a4b58cdd33 100644 --- a/packages/node-integration-tests/suites/public-api/capture-exception/scenario.ts +++ b/packages/node-integration-tests/suites/public-api/captureException/empty-obj/scenario.ts @@ -5,4 +5,4 @@ Sentry.init({ release: '1.0', }); -Sentry.captureException(new Error('Captured Error')); +Sentry.captureException({}); diff --git a/packages/node-integration-tests/suites/public-api/capture-exception/test.ts b/packages/node-integration-tests/suites/public-api/captureException/empty-obj/test.ts similarity index 54% rename from packages/node-integration-tests/suites/public-api/capture-exception/test.ts rename to packages/node-integration-tests/suites/public-api/captureException/empty-obj/test.ts index 3911d6b57c85..fb6ca293a27f 100644 --- a/packages/node-integration-tests/suites/public-api/capture-exception/test.ts +++ b/packages/node-integration-tests/suites/public-api/captureException/empty-obj/test.ts @@ -1,6 +1,6 @@ -import { assertSentryEvent, getEventRequest, runServer } from '../../../utils'; +import { assertSentryEvent, getEventRequest, runServer } from '../../../../utils'; -test('should send captureException', async () => { +test('should capture an empty object', async () => { const url = await runServer(__dirname); const requestBody = await getEventRequest(url); @@ -9,7 +9,11 @@ test('should send captureException', async () => { values: [ { type: 'Error', - value: 'Captured Error', + value: 'Non-Error exception captured with keys: [object has no keys]', + mechanism: { + type: 'generic', + handled: true, + }, }, ], }, diff --git a/packages/node-integration-tests/suites/public-api/captureException/simple-error/scenario.ts b/packages/node-integration-tests/suites/public-api/captureException/simple-error/scenario.ts new file mode 100644 index 000000000000..44366bd34b89 --- /dev/null +++ b/packages/node-integration-tests/suites/public-api/captureException/simple-error/scenario.ts @@ -0,0 +1,8 @@ +import * as Sentry from '@sentry/node'; + +Sentry.init({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + release: '1.0', +}); + +Sentry.captureException(new Error('test_simple_error')); diff --git a/packages/node-integration-tests/suites/public-api/captureException/simple-error/test.ts b/packages/node-integration-tests/suites/public-api/captureException/simple-error/test.ts new file mode 100644 index 000000000000..8553cb1be0d7 --- /dev/null +++ b/packages/node-integration-tests/suites/public-api/captureException/simple-error/test.ts @@ -0,0 +1,24 @@ +import { assertSentryEvent, getEventRequest, runServer } from '../../../../utils'; + +test('should capture a simple error with message', async () => { + const url = await runServer(__dirname); + const requestBody = await getEventRequest(url); + + assertSentryEvent(requestBody, { + exception: { + values: [ + { + type: 'Error', + value: 'test_simple_error', + mechanism: { + type: 'generic', + handled: true, + }, + stacktrace: { + frames: expect.any(Array), + }, + }, + ], + }, + }); +});