Skip to content

Commit 474a64c

Browse files
authored
test(browser): Add test showing behavior of capturing built-in class instances (#16638)
This is not really ideal, but there is no great alternative for this that I can think of to handle this generically 😬 Now at least we have a test showing the current behavior!
1 parent 8f9b9df commit 474a64c

File tree

3 files changed

+22
-1
lines changed
  • dev-packages/browser-integration-tests/suites/public-api/captureException

3 files changed

+22
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Sentry.captureException(new Response('test body'));
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { expect } from '@playwright/test';
2+
import type { Event } from '@sentry/core';
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
5+
6+
sentryTest('should capture a class instance of a built-in class', async ({ getLocalTestUrl, page }) => {
7+
const url = await getLocalTestUrl({ testDir: __dirname });
8+
9+
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
10+
11+
expect(eventData.exception?.values).toHaveLength(1);
12+
expect(eventData.exception?.values?.[0]).toMatchObject({
13+
type: 'Error',
14+
value: '[object Response]',
15+
mechanism: {
16+
type: 'generic',
17+
handled: true,
18+
},
19+
});
20+
});

dev-packages/browser-integration-tests/suites/public-api/captureException/classInstance/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Event } from '@sentry/core';
33
import { sentryTest } from '../../../../utils/fixtures';
44
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
55

6-
sentryTest('should capture an POJO', async ({ getLocalTestUrl, page }) => {
6+
sentryTest('should capture an class instance', async ({ getLocalTestUrl, page }) => {
77
const url = await getLocalTestUrl({ testDir: __dirname });
88

99
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

0 commit comments

Comments
 (0)