-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
75 lines (70 loc) · 2.11 KB
/
test.ts
File metadata and controls
75 lines (70 loc) · 2.11 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { expect } from '@playwright/test';
import type { Event } from '@sentry/core';
import { sentryTest } from '../../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../../utils/helpers';
sentryTest(
'works with a Request (with body) & options passed in - handling used body',
async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });
await page.route('**/foo', route => {
return route.fulfill({
status: 500,
body: JSON.stringify({
error: {
message: 'Internal Server Error',
},
}),
headers: {
'Content-Type': 'text/html',
},
});
});
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
expect(eventData.exception?.values).toHaveLength(1);
// Not able to get the cookies from the request/response because of Playwright bug
// https://github.com/microsoft/playwright/issues/11035
expect(eventData).toMatchObject({
message: 'HTTP Client Error with status code: 500',
exception: {
values: [
{
type: 'Error',
value: 'HTTP Client Error with status code: 500',
mechanism: {
type: 'auto.http.client.fetch',
handled: false,
},
stacktrace: {
frames: expect.arrayContaining([
expect.objectContaining({
filename: 'http://sentry-test.io/subject.bundle.js',
function: '?',
in_app: true,
}),
]),
},
},
],
},
request: {
url: 'http://sentry-test.io/foo',
method: 'POST',
headers: {
accept: 'application/json',
cache: 'no-cache',
'content-type': 'application/json',
},
},
contexts: {
response: {
status_code: 500,
body_size: 45,
headers: {
'content-type': 'text/html',
'content-length': '45',
},
},
},
});
},
);