@@ -9,12 +9,12 @@ import {
9
9
shouldSkipTracingTest ,
10
10
} from '../../../../utils/helpers' ;
11
11
12
- sentryTest ( 'creates a new trace on each navigation' , async ( { getLocalTestPath , page } ) => {
12
+ sentryTest ( 'creates a new trace on each navigation' , async ( { getLocalTestUrl , page } ) => {
13
13
if ( shouldSkipTracingTest ( ) ) {
14
14
sentryTest . skip ( ) ;
15
15
}
16
16
17
- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
17
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
18
18
19
19
await getFirstSentryEnvelopeRequest ( page , url ) ;
20
20
@@ -32,6 +32,9 @@ sentryTest('creates a new trace on each navigation', async ({ getLocalTestPath,
32
32
const navigation1TraceContext = navigation1Event . contexts ?. trace ;
33
33
const navigation2TraceContext = navigation2Event . contexts ?. trace ;
34
34
35
+ expect ( navigation1Event . type ) . toEqual ( 'transaction' ) ;
36
+ expect ( navigation2Event . type ) . toEqual ( 'transaction' ) ;
37
+
35
38
expect ( navigation1TraceContext ) . toMatchObject ( {
36
39
op : 'navigation' ,
37
40
trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -65,12 +68,12 @@ sentryTest('creates a new trace on each navigation', async ({ getLocalTestPath,
65
68
expect ( navigation1TraceContext ?. trace_id ) . not . toEqual ( navigation2TraceContext ?. trace_id ) ;
66
69
} ) ;
67
70
68
- sentryTest ( 'error after navigation has navigation traceId' , async ( { getLocalTestPath , page } ) => {
71
+ sentryTest ( 'error after navigation has navigation traceId' , async ( { getLocalTestUrl , page } ) => {
69
72
if ( shouldSkipTracingTest ( ) ) {
70
73
sentryTest . skip ( ) ;
71
74
}
72
75
73
- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
76
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
74
77
75
78
// ensure pageload transaction is finished
76
79
await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
@@ -82,6 +85,8 @@ sentryTest('error after navigation has navigation traceId', async ({ getLocalTes
82
85
) ;
83
86
const navigationTraceContext = navigationEvent . contexts ?. trace ;
84
87
88
+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
89
+
85
90
expect ( navigationTraceContext ) . toMatchObject ( {
86
91
op : 'navigation' ,
87
92
trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -105,6 +110,8 @@ sentryTest('error after navigation has navigation traceId', async ({ getLocalTes
105
110
await page . locator ( '#errorBtn' ) . click ( ) ;
106
111
const [ errorEvent , errorTraceHeader ] = await errorEventPromise ;
107
112
113
+ expect ( errorEvent . type ) . toEqual ( undefined ) ;
114
+
108
115
const errorTraceContext = errorEvent . contexts ?. trace ;
109
116
expect ( errorTraceContext ) . toEqual ( {
110
117
trace_id : navigationTraceContext ?. trace_id ,
@@ -119,12 +126,12 @@ sentryTest('error after navigation has navigation traceId', async ({ getLocalTes
119
126
} ) ;
120
127
} ) ;
121
128
122
- sentryTest ( 'error during navigation has new navigation traceId' , async ( { getLocalTestPath , page } ) => {
129
+ sentryTest ( 'error during navigation has new navigation traceId' , async ( { getLocalTestUrl , page } ) => {
123
130
if ( shouldSkipTracingTest ( ) ) {
124
131
sentryTest . skip ( ) ;
125
132
}
126
133
127
- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
134
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
128
135
129
136
// ensure navigation transaction is finished
130
137
await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
@@ -143,6 +150,9 @@ sentryTest('error during navigation has new navigation traceId', async ({ getLoc
143
150
const [ navigationEvent , navigationTraceHeader ] = envelopes . find ( envelope => envelope [ 0 ] . type === 'transaction' ) ! ;
144
151
const [ errorEvent , errorTraceHeader ] = envelopes . find ( envelope => ! envelope [ 0 ] . type ) ! ;
145
152
153
+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
154
+ expect ( errorEvent . type ) . toEqual ( undefined ) ;
155
+
146
156
const navigationTraceContext = navigationEvent ?. contexts ?. trace ;
147
157
expect ( navigationTraceContext ) . toMatchObject ( {
148
158
op : 'navigation' ,
@@ -161,14 +171,6 @@ sentryTest('error during navigation has new navigation traceId', async ({ getLoc
161
171
162
172
const errorTraceContext = errorEvent ?. contexts ?. trace ;
163
173
expect ( errorTraceContext ) . toEqual ( {
164
- data : {
165
- 'sentry.op' : 'navigation' ,
166
- 'sentry.origin' : 'auto.navigation.browser' ,
167
- 'sentry.sample_rate' : 1 ,
168
- 'sentry.source' : 'url' ,
169
- } ,
170
- op : 'navigation' ,
171
- origin : 'auto.navigation.browser' ,
172
174
trace_id : navigationTraceContext ?. trace_id ,
173
175
span_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 16 } $ / ) ,
174
176
} ) ;
@@ -184,12 +186,20 @@ sentryTest('error during navigation has new navigation traceId', async ({ getLoc
184
186
185
187
sentryTest (
186
188
'outgoing fetch request after navigation has navigation traceId in headers' ,
187
- async ( { getLocalTestPath , page } ) => {
189
+ async ( { getLocalTestUrl , page } ) => {
188
190
if ( shouldSkipTracingTest ( ) ) {
189
191
sentryTest . skip ( ) ;
190
192
}
191
193
192
- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
194
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
195
+
196
+ await page . route ( 'http://example.com/**' , route => {
197
+ return route . fulfill ( {
198
+ status : 200 ,
199
+ contentType : 'application/json' ,
200
+ body : JSON . stringify ( { } ) ,
201
+ } ) ;
202
+ } ) ;
193
203
194
204
// ensure navigation transaction is finished
195
205
await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
@@ -201,6 +211,8 @@ sentryTest(
201
211
) ;
202
212
203
213
const navigationTraceContext = navigationEvent . contexts ?. trace ;
214
+
215
+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
204
216
expect ( navigationTraceContext ) . toMatchObject ( {
205
217
op : 'navigation' ,
206
218
trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -232,12 +244,20 @@ sentryTest(
232
244
233
245
sentryTest (
234
246
'outgoing fetch request during navigation has navigation traceId in headers' ,
235
- async ( { getLocalTestPath , page } ) => {
247
+ async ( { getLocalTestUrl , page } ) => {
236
248
if ( shouldSkipTracingTest ( ) ) {
237
249
sentryTest . skip ( ) ;
238
250
}
239
251
240
- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
252
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
253
+
254
+ await page . route ( 'http://example.com/**' , route => {
255
+ return route . fulfill ( {
256
+ status : 200 ,
257
+ contentType : 'application/json' ,
258
+ body : JSON . stringify ( { } ) ,
259
+ } ) ;
260
+ } ) ;
241
261
242
262
// ensure navigation transaction is finished
243
263
await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
@@ -256,6 +276,8 @@ sentryTest(
256
276
] ) ;
257
277
258
278
const navigationTraceContext = navigationEvent . contexts ?. trace ;
279
+
280
+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
259
281
expect ( navigationTraceContext ) . toMatchObject ( {
260
282
op : 'navigation' ,
261
283
trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -284,12 +306,20 @@ sentryTest(
284
306
285
307
sentryTest (
286
308
'outgoing XHR request after navigation has navigation traceId in headers' ,
287
- async ( { getLocalTestPath , page } ) => {
309
+ async ( { getLocalTestUrl , page } ) => {
288
310
if ( shouldSkipTracingTest ( ) ) {
289
311
sentryTest . skip ( ) ;
290
312
}
291
313
292
- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
314
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
315
+
316
+ await page . route ( 'http://example.com/**' , route => {
317
+ return route . fulfill ( {
318
+ status : 200 ,
319
+ contentType : 'application/json' ,
320
+ body : JSON . stringify ( { } ) ,
321
+ } ) ;
322
+ } ) ;
293
323
294
324
// ensure navigation transaction is finished
295
325
await getFirstSentryEnvelopeRequest ( page , url ) ;
@@ -301,6 +331,8 @@ sentryTest(
301
331
) ;
302
332
303
333
const navigationTraceContext = navigationEvent . contexts ?. trace ;
334
+
335
+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
304
336
expect ( navigationTraceContext ) . toMatchObject ( {
305
337
op : 'navigation' ,
306
338
trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -332,12 +364,20 @@ sentryTest(
332
364
333
365
sentryTest (
334
366
'outgoing XHR request during navigation has navigation traceId in headers' ,
335
- async ( { getLocalTestPath , page } ) => {
367
+ async ( { getLocalTestUrl , page } ) => {
336
368
if ( shouldSkipTracingTest ( ) ) {
337
369
sentryTest . skip ( ) ;
338
370
}
339
371
340
- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
372
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
373
+
374
+ await page . route ( 'http://example.com/**' , route => {
375
+ return route . fulfill ( {
376
+ status : 200 ,
377
+ contentType : 'application/json' ,
378
+ body : JSON . stringify ( { } ) ,
379
+ } ) ;
380
+ } ) ;
341
381
342
382
// ensure navigation transaction is finished
343
383
await getFirstSentryEnvelopeRequest ( page , url ) ;
@@ -356,6 +396,8 @@ sentryTest(
356
396
] ) ;
357
397
358
398
const navigationTraceContext = navigationEvent . contexts ?. trace ;
399
+
400
+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
359
401
expect ( navigationTraceContext ) . toMatchObject ( {
360
402
op : 'navigation' ,
361
403
trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
0 commit comments