Skip to content

Commit aeb2be0

Browse files
committed
add tests
1 parent 5b9d3bb commit aeb2be0

File tree

2 files changed

+46
-6
lines changed
  • dev-packages/browser-integration-tests
    • loader-suites/loader/noOnLoad/captureException
    • suites/public-api/captureException/simpleError

2 files changed

+46
-6
lines changed

dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/captureException/test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect } from '@playwright/test';
2+
import { SDK_VERSION } from '@sentry/browser';
23

34
import { sentryTest } from '../../../../utils/fixtures';
45
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';
@@ -11,3 +12,22 @@ sentryTest('captureException works', async ({ getLocalTestUrl, page }) => {
1112

1213
expect(eventData.message).toBe('Test exception');
1314
});
15+
16+
sentryTest('should capture a correct SDK metadata', async ({ getLocalTestUrl, page }) => {
17+
const url = await getLocalTestUrl({ testDir: __dirname });
18+
const req = await waitForErrorRequestOnUrl(page, url);
19+
20+
const eventData = envelopeRequestParser(req);
21+
22+
expect(eventData.sdk).toMatchObject({
23+
name: 'sentry.javascript.browser',
24+
version: SDK_VERSION,
25+
integrations: expect.any(Object),
26+
packages: [
27+
{
28+
name: 'loader:@sentry/browser',
29+
version: SDK_VERSION,
30+
},
31+
],
32+
});
33+
});

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { expect } from '@playwright/test';
2-
import type { Event } from '@sentry/types';
2+
import { SDK_VERSION } from '@sentry/browser';
33

44
import { sentryTest } from '../../../../utils/fixtures';
5-
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
5+
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';
66

7-
sentryTest('should capture a simple error with message', async ({ getLocalTestPath, page }) => {
8-
const url = await getLocalTestPath({ testDir: __dirname });
9-
10-
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
7+
sentryTest('should capture a simple error with message', async ({ getLocalTestUrl, page }) => {
8+
const url = await getLocalTestUrl({ testDir: __dirname });
9+
const req = await waitForErrorRequestOnUrl(page, url);
10+
const eventData = envelopeRequestParser(req);
1111

1212
expect(eventData.exception?.values).toHaveLength(1);
1313
expect(eventData.exception?.values?.[0]).toMatchObject({
@@ -22,3 +22,23 @@ sentryTest('should capture a simple error with message', async ({ getLocalTestPa
2222
},
2323
});
2424
});
25+
26+
sentryTest('should capture a correct SDK metadata', async ({ getLocalTestUrl, page }) => {
27+
const isCdn = (process.env.PW_BUNDLE || '').startsWith('bundle');
28+
29+
const url = await getLocalTestUrl({ testDir: __dirname });
30+
const req = await waitForErrorRequestOnUrl(page, url);
31+
const eventData = envelopeRequestParser(req);
32+
33+
expect(eventData.sdk).toEqual({
34+
name: 'sentry.javascript.browser',
35+
version: SDK_VERSION,
36+
integrations: expect.any(Object),
37+
packages: [
38+
{
39+
name: `${isCdn ? 'cdn' : 'npm'}:@sentry/browser`,
40+
version: SDK_VERSION,
41+
},
42+
],
43+
});
44+
});

0 commit comments

Comments
 (0)