Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as Sentry from '@sentry/node';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
});

try {
throw new Error('catched_error');
} catch (err) {
Sentry.captureException(err);
}
Original file line number Diff line number Diff line change
@@ -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),
},
},
],
},
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Sentry.init({
release: '1.0',
});

Sentry.captureException(new Error('Captured Error'));
Sentry.captureException({});
Original file line number Diff line number Diff line change
@@ -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);

Expand All @@ -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,
},
},
],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as Sentry from '@sentry/node';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
});

Sentry.captureException(new Error('test_simple_error'));
Original file line number Diff line number Diff line change
@@ -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),
},
},
],
},
});
});