Skip to content

Commit f104112

Browse files
authored
test(node): Add setExtras integration tests (#4792)
1 parent d5aaf2a commit f104112

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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.setExtras({ extra: [] });
9+
Sentry.setExtras({ null: 0 });
10+
Sentry.setExtras({
11+
obj: {
12+
foo: ['bar', 'baz', 1],
13+
},
14+
});
15+
Sentry.setExtras({ [Infinity]: 2 });
16+
17+
Sentry.captureMessage('consecutive_calls');
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { assertSentryEvent, getEventRequest, runServer } from '../../../../utils';
2+
3+
test('should set extras from multiple consecutive calls', async () => {
4+
const url = await runServer(__dirname);
5+
const requestBody = await getEventRequest(url);
6+
7+
assertSentryEvent(requestBody, {
8+
message: 'consecutive_calls',
9+
extra: { extra: [], Infinity: 2, null: 0, obj: { foo: ['bar', 'baz', 1] } },
10+
});
11+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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.setExtras({
9+
extra_1: [1, ['foo'], 'bar'],
10+
extra_2: 'baz',
11+
extra_3: Math.PI,
12+
extra_4: {
13+
qux: {
14+
quux: false,
15+
},
16+
},
17+
});
18+
19+
Sentry.captureMessage('multiple_extras');
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { assertSentryEvent, getEventRequest, runServer } from '../../../../utils';
2+
3+
test('should record an extras object', async () => {
4+
const url = await runServer(__dirname);
5+
const requestBody = await getEventRequest(url);
6+
7+
assertSentryEvent(requestBody, {
8+
message: 'multiple_extras',
9+
extra: {
10+
extra_1: [1, ['foo'], 'bar'],
11+
extra_2: 'baz',
12+
extra_3: 3.141592653589793,
13+
extra_4: { qux: { quux: false } },
14+
},
15+
});
16+
});

0 commit comments

Comments
 (0)