@@ -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' ,
@@ -176,12 +186,20 @@ sentryTest('error during navigation has new navigation traceId', async ({ getLoc
176
186
177
187
sentryTest (
178
188
'outgoing fetch request after navigation has navigation traceId in headers' ,
179
- async ( { getLocalTestPath , page } ) => {
189
+ async ( { getLocalTestUrl , page } ) => {
180
190
if ( shouldSkipTracingTest ( ) ) {
181
191
sentryTest . skip ( ) ;
182
192
}
183
193
184
- 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
+ } ) ;
185
203
186
204
// ensure navigation transaction is finished
187
205
await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
@@ -193,6 +211,8 @@ sentryTest(
193
211
) ;
194
212
195
213
const navigationTraceContext = navigationEvent . contexts ?. trace ;
214
+
215
+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
196
216
expect ( navigationTraceContext ) . toMatchObject ( {
197
217
op : 'navigation' ,
198
218
trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -224,12 +244,20 @@ sentryTest(
224
244
225
245
sentryTest (
226
246
'outgoing fetch request during navigation has navigation traceId in headers' ,
227
- async ( { getLocalTestPath , page } ) => {
247
+ async ( { getLocalTestUrl , page } ) => {
228
248
if ( shouldSkipTracingTest ( ) ) {
229
249
sentryTest . skip ( ) ;
230
250
}
231
251
232
- 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
+ } ) ;
233
261
234
262
// ensure navigation transaction is finished
235
263
await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
@@ -248,6 +276,8 @@ sentryTest(
248
276
] ) ;
249
277
250
278
const navigationTraceContext = navigationEvent . contexts ?. trace ;
279
+
280
+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
251
281
expect ( navigationTraceContext ) . toMatchObject ( {
252
282
op : 'navigation' ,
253
283
trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -276,12 +306,20 @@ sentryTest(
276
306
277
307
sentryTest (
278
308
'outgoing XHR request after navigation has navigation traceId in headers' ,
279
- async ( { getLocalTestPath , page } ) => {
309
+ async ( { getLocalTestUrl , page } ) => {
280
310
if ( shouldSkipTracingTest ( ) ) {
281
311
sentryTest . skip ( ) ;
282
312
}
283
313
284
- 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
+ } ) ;
285
323
286
324
// ensure navigation transaction is finished
287
325
await getFirstSentryEnvelopeRequest ( page , url ) ;
@@ -293,6 +331,8 @@ sentryTest(
293
331
) ;
294
332
295
333
const navigationTraceContext = navigationEvent . contexts ?. trace ;
334
+
335
+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
296
336
expect ( navigationTraceContext ) . toMatchObject ( {
297
337
op : 'navigation' ,
298
338
trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -324,12 +364,20 @@ sentryTest(
324
364
325
365
sentryTest (
326
366
'outgoing XHR request during navigation has navigation traceId in headers' ,
327
- async ( { getLocalTestPath , page } ) => {
367
+ async ( { getLocalTestUrl , page } ) => {
328
368
if ( shouldSkipTracingTest ( ) ) {
329
369
sentryTest . skip ( ) ;
330
370
}
331
371
332
- 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
+ } ) ;
333
381
334
382
// ensure navigation transaction is finished
335
383
await getFirstSentryEnvelopeRequest ( page , url ) ;
@@ -348,6 +396,8 @@ sentryTest(
348
396
] ) ;
349
397
350
398
const navigationTraceContext = navigationEvent . contexts ?. trace ;
399
+
400
+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
351
401
expect ( navigationTraceContext ) . toMatchObject ( {
352
402
op : 'navigation' ,
353
403
trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
0 commit comments