-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathtest.ts
50 lines (46 loc) · 1.5 KB
/
test.ts
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
47
48
49
50
import { expect } from '@playwright/test';
import type { Event } from '@sentry/core';
import { sentryTest } from '../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers';
sentryTest('allows to setup a client manually & capture exceptions', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
expect(eventData).toEqual({
exception: {
values: [
expect.objectContaining({
type: 'Error',
value: 'test client',
mechanism: {
type: 'generic',
handled: true,
},
stacktrace: {
frames: expect.any(Array),
},
}),
],
},
level: 'error',
event_id: expect.any(String),
platform: 'javascript',
request: {
url,
headers: expect.objectContaining({
'User-Agent': expect.any(String),
}),
},
timestamp: expect.any(Number),
environment: 'local',
release: '0.0.1',
sdk: {
integrations: ['Breadcrumbs', 'FunctionToString', 'Dedupe', 'HttpContext', 'EventFilters', 'LinkedErrors'],
name: 'sentry.javascript.browser',
version: expect.any(String),
packages: [{ name: expect.any(String), version: expect.any(String) }],
},
contexts: {
trace: { trace_id: expect.stringMatching(/[a-f0-9]{32}/), span_id: expect.stringMatching(/[a-f0-9]{16}/) },
},
});
});