Skip to content

Commit 15773ba

Browse files
authored
test(browser): Add integration tests for setExtras (#4347)
1 parent c90764b commit 15773ba

File tree

6 files changed

+72
-0
lines changed

6 files changed

+72
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Sentry.setExtras({ extra: [] });
2+
Sentry.setExtras({ null: 0 });
3+
Sentry.setExtras({
4+
obj: {
5+
foo: ['bar', 'baz', 1],
6+
},
7+
});
8+
Sentry.setExtras({ [null]: Infinity });
9+
Sentry.setExtras({ [Infinity]: 2 });
10+
11+
Sentry.captureMessage('consecutive_calls');
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import { getSentryRequest } from '../../../../utils/helpers';
5+
6+
sentryTest('should set extras from multiple consecutive calls', async ({ getLocalTestPath, page }) => {
7+
const url = await getLocalTestPath({ testDir: __dirname });
8+
9+
const eventData = await getSentryRequest(page, url);
10+
11+
expect(eventData.message).toBe('consecutive_calls');
12+
expect(eventData.extra).toMatchObject({ extra: [], Infinity: 2, null: null, obj: { foo: ['bar', 'baz', 1] } });
13+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Sentry.setExtras({
2+
extra_1: [1, ['foo'], 'bar'],
3+
extra_2: 'baz',
4+
extra_3: Math.PI,
5+
extra_4: {
6+
qux: {
7+
quux: false,
8+
},
9+
},
10+
});
11+
12+
Sentry.captureMessage('multiple_extras');
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import { getSentryRequest } from '../../../../utils/helpers';
5+
6+
sentryTest('should record an extras object', async ({ getLocalTestPath, page }) => {
7+
const url = await getLocalTestPath({ testDir: __dirname });
8+
9+
const eventData = await getSentryRequest(page, url);
10+
11+
expect(eventData.message).toBe('multiple_extras');
12+
expect(eventData.extra).toMatchObject({
13+
extra_1: [1, ['foo'], 'bar'],
14+
extra_2: 'baz',
15+
extra_3: 3.141592653589793,
16+
extra_4: { qux: { quux: false } },
17+
});
18+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title></title>
6+
<script src="{{htmlWebpackPlugin.options.initialization}}"></script>
7+
</head>
8+
<body>
9+
<script src="{{htmlWebpackPlugin.options.subject}}"></script>
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)