Skip to content

Commit 8716b2e

Browse files
committed
test(node): Add addBreadcrumb integration tests.
1 parent 1c84fce commit 8716b2e

File tree

6 files changed

+88
-0
lines changed

6 files changed

+88
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as Sentry from '@sentry/node';
2+
3+
Sentry.init({
4+
dsn: 'https://[email protected]/1337',
5+
release: '1.0',
6+
});
7+
8+
Sentry.addBreadcrumb({});
9+
Sentry.captureMessage('test-empty-obj');
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { assertSentryEvent, getEventRequest, runServer } from '../../../../utils';
2+
3+
test('should add an empty breadcrumb, when an empty object is given', async () => {
4+
const url = await runServer(__dirname);
5+
const requestBody = await getEventRequest(url);
6+
7+
assertSentryEvent(requestBody, {
8+
message: 'test-empty-obj',
9+
});
10+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as Sentry from '@sentry/node';
2+
3+
Sentry.init({
4+
dsn: 'https://[email protected]/1337',
5+
release: '1.0',
6+
});
7+
8+
Sentry.addBreadcrumb({
9+
category: 'foo',
10+
message: 'bar',
11+
level: Sentry.Severity.Critical,
12+
});
13+
14+
Sentry.addBreadcrumb({
15+
category: 'qux',
16+
});
17+
18+
Sentry.captureMessage('test_multi_breadcrumbs');
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { assertSentryEvent, getEventRequest, runServer } from '../../../../utils';
2+
3+
test('should add multiple breadcrumbs', async () => {
4+
const url = await runServer(__dirname);
5+
const requestBody = await getEventRequest(url);
6+
7+
assertSentryEvent(requestBody, {
8+
message: 'test_multi_breadcrumbs',
9+
breadcrumbs: [
10+
{
11+
category: 'foo',
12+
message: 'bar',
13+
level: 'critical',
14+
},
15+
{
16+
category: 'qux',
17+
},
18+
],
19+
});
20+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as Sentry from '@sentry/node';
2+
3+
Sentry.init({
4+
dsn: 'https://[email protected]/1337',
5+
release: '1.0',
6+
});
7+
8+
Sentry.addBreadcrumb({
9+
category: 'foo',
10+
message: 'bar',
11+
level: Sentry.Severity.Critical,
12+
});
13+
14+
Sentry.captureMessage('test_simple');
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { assertSentryEvent, getEventRequest, runServer } from '../../../../utils';
2+
3+
test('should add a simple breadcrumb', async () => {
4+
const url = await runServer(__dirname);
5+
const requestBody = await getEventRequest(url);
6+
7+
assertSentryEvent(requestBody, {
8+
message: 'test_simple',
9+
breadcrumbs: [
10+
{
11+
category: 'foo',
12+
message: 'bar',
13+
level: 'critical',
14+
},
15+
],
16+
});
17+
});

0 commit comments

Comments
 (0)