-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
161 lines (157 loc) · 6.17 KB
/
test.ts
File metadata and controls
161 lines (157 loc) · 6.17 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import { expect } from '@playwright/test';
import type { LogEnvelope } from '@sentry/core';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest, properFullEnvelopeRequestParser } from '../../../../utils/helpers';
sentryTest('should capture console object calls', async ({ getLocalTestUrl, page }) => {
const bundle = process.env.PW_BUNDLE || '';
// Only run this for npm package exports
if (bundle.startsWith('bundle') || bundle.startsWith('loader')) {
sentryTest.skip();
}
const url = await getLocalTestUrl({ testDir: __dirname });
const event = await getFirstSentryEnvelopeRequest<LogEnvelope>(page, url, properFullEnvelopeRequestParser);
const envelopeItems = event[1];
expect(envelopeItems[0]).toEqual([
{
type: 'log',
item_count: 11,
content_type: 'application/vnd.sentry.items.log+json',
},
{
items: [
{
timestamp: expect.any(Number),
level: 'trace',
severity_number: 1,
trace_id: expect.any(String),
body: 'console.trace 123 false',
attributes: {
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'debug',
severity_number: 5,
trace_id: expect.any(String),
body: 'console.debug 123 false',
attributes: {
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'info',
severity_number: 10,
trace_id: expect.any(String),
body: 'console.log 123 false',
attributes: {
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'info',
severity_number: 9,
trace_id: expect.any(String),
body: 'console.info 123 false',
attributes: {
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'warn',
severity_number: 13,
trace_id: expect.any(String),
body: 'console.warn 123 false',
attributes: {
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'error',
severity_number: 17,
trace_id: expect.any(String),
body: 'console.error 123 false',
attributes: {
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'error',
severity_number: 17,
trace_id: expect.any(String),
body: 'Assertion failed: console.assert 123 false',
attributes: {
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'info',
severity_number: 10,
trace_id: expect.any(String),
body: 'Object: {"key":"value","nested":{"prop":123}}',
attributes: {
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'info',
severity_number: 10,
trace_id: expect.any(String),
body: 'Array: [1,2,3,"string"]',
attributes: {
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'info',
severity_number: 10,
trace_id: expect.any(String),
body: 'Mixed: prefix {"obj":true} [4,5,6] suffix',
attributes: {
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'info',
severity_number: 10,
trace_id: expect.any(String),
body: '',
attributes: {
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
],
},
]);
});