From bcbd443a716a386915ea6d34a8fa7aa9870cf82f Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 18 Jun 2025 11:57:05 +0200 Subject: [PATCH] test(browser): Add test showing behavior of capturing built-in class instances --- .../builtInClassInstance/subject.js | 1 + .../builtInClassInstance/test.ts | 20 +++++++++++++++++++ .../captureException/classInstance/test.ts | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 dev-packages/browser-integration-tests/suites/public-api/captureException/builtInClassInstance/subject.js create mode 100644 dev-packages/browser-integration-tests/suites/public-api/captureException/builtInClassInstance/test.ts diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureException/builtInClassInstance/subject.js b/dev-packages/browser-integration-tests/suites/public-api/captureException/builtInClassInstance/subject.js new file mode 100644 index 000000000000..556cd5babb09 --- /dev/null +++ b/dev-packages/browser-integration-tests/suites/public-api/captureException/builtInClassInstance/subject.js @@ -0,0 +1 @@ +Sentry.captureException(new Response('test body')); diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureException/builtInClassInstance/test.ts b/dev-packages/browser-integration-tests/suites/public-api/captureException/builtInClassInstance/test.ts new file mode 100644 index 000000000000..4f93b7b87d44 --- /dev/null +++ b/dev-packages/browser-integration-tests/suites/public-api/captureException/builtInClassInstance/test.ts @@ -0,0 +1,20 @@ +import { expect } from '@playwright/test'; +import type { Event } from '@sentry/core'; +import { sentryTest } from '../../../../utils/fixtures'; +import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; + +sentryTest('should capture a class instance of a built-in class', async ({ getLocalTestUrl, page }) => { + const url = await getLocalTestUrl({ testDir: __dirname }); + + const eventData = await getFirstSentryEnvelopeRequest(page, url); + + expect(eventData.exception?.values).toHaveLength(1); + expect(eventData.exception?.values?.[0]).toMatchObject({ + type: 'Error', + value: '[object Response]', + mechanism: { + type: 'generic', + handled: true, + }, + }); +}); diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureException/classInstance/test.ts b/dev-packages/browser-integration-tests/suites/public-api/captureException/classInstance/test.ts index 5cdd446a1510..19349532282e 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/captureException/classInstance/test.ts +++ b/dev-packages/browser-integration-tests/suites/public-api/captureException/classInstance/test.ts @@ -3,7 +3,7 @@ import type { Event } from '@sentry/core'; import { sentryTest } from '../../../../utils/fixtures'; import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; -sentryTest('should capture an POJO', async ({ getLocalTestUrl, page }) => { +sentryTest('should capture an class instance', async ({ getLocalTestUrl, page }) => { const url = await getLocalTestUrl({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url);