-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
46 lines (41 loc) · 1.42 KB
/
test.ts
File metadata and controls
46 lines (41 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { expect } from '@playwright/test';
import { SDK_VERSION } from '@sentry/browser';
import { sentryTest } from '../../../../utils/fixtures';
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';
sentryTest('should capture a simple error with message', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForErrorRequestOnUrl(page, url);
const eventData = envelopeRequestParser(req);
expect(eventData.exception?.values).toHaveLength(1);
expect(eventData.exception?.values?.[0]).toMatchObject({
type: 'Error',
value: 'test_simple_error',
mechanism: {
type: 'generic',
handled: true,
},
stacktrace: {
frames: expect.any(Array),
},
});
});
sentryTest('should capture correct SDK metadata', async ({ getLocalTestUrl, page }) => {
const isCdn = (process.env.PW_BUNDLE || '').startsWith('bundle');
const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForErrorRequestOnUrl(page, url);
const eventData = envelopeRequestParser(req);
expect(eventData.sdk).toEqual({
name: 'sentry.javascript.browser',
version: SDK_VERSION,
integrations: expect.any(Object),
packages: [
{
name: `${isCdn ? 'cdn' : 'npm'}:@sentry/browser`,
version: SDK_VERSION,
},
],
settings: {
infer_ip: 'never',
},
});
});