-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
116 lines (105 loc) · 2.81 KB
/
test.ts
File metadata and controls
116 lines (105 loc) · 2.81 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
import { expect } from '@playwright/test';
import type { OtelLogEnvelope } 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<OtelLogEnvelope>(page, url, properFullEnvelopeRequestParser);
const envelopeItems = event[1];
expect(envelopeItems[0]).toEqual([
{
type: 'otel_log',
},
{
severityText: 'trace',
body: { stringValue: 'console.trace 123 false' },
attributes: [],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 1,
},
]);
expect(envelopeItems[1]).toEqual([
{
type: 'otel_log',
},
{
severityText: 'debug',
body: { stringValue: 'console.debug 123 false' },
attributes: [],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 5,
},
]);
expect(envelopeItems[2]).toEqual([
{
type: 'otel_log',
},
{
severityText: 'info',
body: { stringValue: 'console.log 123 false' },
attributes: [],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 10,
},
]);
expect(envelopeItems[3]).toEqual([
{
type: 'otel_log',
},
{
severityText: 'info',
body: { stringValue: 'console.info 123 false' },
attributes: [],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 9,
},
]);
expect(envelopeItems[4]).toEqual([
{
type: 'otel_log',
},
{
severityText: 'warn',
body: { stringValue: 'console.warn 123 false' },
attributes: [],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 13,
},
]);
expect(envelopeItems[5]).toEqual([
{
type: 'otel_log',
},
{
severityText: 'error',
body: { stringValue: 'console.error 123 false' },
attributes: [],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 17,
},
]);
expect(envelopeItems[6]).toEqual([
{
type: 'otel_log',
},
{
severityText: 'error',
body: { stringValue: 'Assertion failed: console.assert 123 false' },
attributes: [],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 17,
},
]);
});