8
8
shouldSkipReplayTest ,
9
9
} from '../../../../../utils/replayHelpers' ;
10
10
11
- // Skipping because this test is flaky
12
- // https://github.com/getsentry/sentry-javascript/issues/11062
13
- sentryTest . skip ( 'handles empty/missing request headers' , async ( { getLocalTestPath, page, browserName } ) => {
11
+ sentryTest ( 'handles empty/missing request headers' , async ( { getLocalTestPath, page, browserName } ) => {
14
12
if ( shouldSkipReplayTest ( ) ) {
15
13
sentryTest . skip ( ) ;
16
14
}
@@ -37,18 +35,21 @@ sentryTest.skip('handles empty/missing request headers', async ({ getLocalTestPa
37
35
const url = await getLocalTestPath ( { testDir : __dirname } ) ;
38
36
await page . goto ( url ) ;
39
37
40
- await page . evaluate ( ( ) => {
41
- /* eslint-disable */
42
- fetch ( 'http://localhost:7654/foo' , {
43
- method : 'POST' ,
44
- } ) . then ( ( ) => {
45
- // @ts -expect-error Sentry is a global
46
- Sentry . captureException ( 'test error' ) ;
47
- } ) ;
48
- /* eslint-enable */
49
- } ) ;
38
+ const [ , request , { replayRecordingSnapshots } ] = await Promise . all ( [
39
+ page . evaluate ( ( ) => {
40
+ /* eslint-disable */
41
+ fetch ( 'http://localhost:7654/foo' , {
42
+ method : 'POST' ,
43
+ } ) . then ( ( ) => {
44
+ // @ts -expect-error Sentry is a global
45
+ Sentry . captureException ( 'test error' ) ;
46
+ } ) ;
47
+ /* eslint-enable */
48
+ } ) ,
49
+ requestPromise ,
50
+ replayRequestPromise ,
51
+ ] ) ;
50
52
51
- const request = await requestPromise ;
52
53
const eventData = envelopeRequestParser ( request ) ;
53
54
54
55
expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
@@ -65,7 +66,6 @@ sentryTest.skip('handles empty/missing request headers', async ({ getLocalTestPa
65
66
} ,
66
67
} ) ;
67
68
68
- const { replayRecordingSnapshots } = await replayRequestPromise ;
69
69
expect ( getReplayPerformanceSpans ( replayRecordingSnapshots ) . filter ( span => span . op === 'resource.fetch' ) ) . toEqual ( [
70
70
{
71
71
data : {
@@ -110,25 +110,28 @@ sentryTest('captures request headers as POJO', async ({ getLocalTestPath, page,
110
110
const url = await getLocalTestPath ( { testDir : __dirname } ) ;
111
111
await page . goto ( url ) ;
112
112
113
- await page . evaluate ( ( ) => {
114
- /* eslint-disable */
115
- fetch ( 'http://localhost:7654/foo' , {
116
- method : 'POST' ,
117
- headers : {
118
- Accept : 'application/json' ,
119
- 'Content-Type' : 'application/json' ,
120
- Cache : 'no-cache' ,
121
- 'X-Custom-Header' : 'foo' ,
122
- 'X-Test-Header' : 'test-value' ,
123
- } ,
124
- } ) . then ( ( ) => {
125
- // @ts -expect-error Sentry is a global
126
- Sentry . captureException ( 'test error' ) ;
127
- } ) ;
128
- /* eslint-enable */
129
- } ) ;
113
+ const [ , request , { replayRecordingSnapshots } ] = await Promise . all ( [
114
+ page . evaluate ( ( ) => {
115
+ /* eslint-disable */
116
+ fetch ( 'http://localhost:7654/foo' , {
117
+ method : 'POST' ,
118
+ headers : {
119
+ Accept : 'application/json' ,
120
+ 'Content-Type' : 'application/json' ,
121
+ Cache : 'no-cache' ,
122
+ 'X-Custom-Header' : 'foo' ,
123
+ 'X-Test-Header' : 'test-value' ,
124
+ } ,
125
+ } ) . then ( ( ) => {
126
+ // @ts -expect-error Sentry is a global
127
+ Sentry . captureException ( 'test error' ) ;
128
+ } ) ;
129
+ /* eslint-enable */
130
+ } ) ,
131
+ requestPromise ,
132
+ replayRequestPromise ,
133
+ ] ) ;
130
134
131
- const request = await requestPromise ;
132
135
const eventData = envelopeRequestParser ( request ) ;
133
136
134
137
expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
@@ -145,7 +148,6 @@ sentryTest('captures request headers as POJO', async ({ getLocalTestPath, page,
145
148
} ,
146
149
} ) ;
147
150
148
- const { replayRecordingSnapshots } = await replayRequestPromise ;
149
151
expect ( getReplayPerformanceSpans ( replayRecordingSnapshots ) . filter ( span => span . op === 'resource.fetch' ) ) . toEqual ( [
150
152
{
151
153
data : {
@@ -195,25 +197,28 @@ sentryTest('captures request headers on Request', async ({ getLocalTestPath, pag
195
197
const url = await getLocalTestPath ( { testDir : __dirname } ) ;
196
198
await page . goto ( url ) ;
197
199
198
- await page . evaluate ( ( ) => {
199
- const request = new Request ( 'http://localhost:7654/foo' , {
200
- method : 'POST' ,
201
- headers : {
202
- Accept : 'application/json' ,
203
- 'Content-Type' : 'application/json' ,
204
- Cache : 'no-cache' ,
205
- 'X-Custom-Header' : 'foo' ,
206
- } ,
207
- } ) ;
208
- /* eslint-disable */
209
- fetch ( request ) . then ( ( ) => {
210
- // @ts -expect-error Sentry is a global
211
- Sentry . captureException ( 'test error' ) ;
212
- } ) ;
213
- /* eslint-enable */
214
- } ) ;
200
+ const [ , request , { replayRecordingSnapshots } ] = await Promise . all ( [
201
+ page . evaluate ( ( ) => {
202
+ const request = new Request ( 'http://localhost:7654/foo' , {
203
+ method : 'POST' ,
204
+ headers : {
205
+ Accept : 'application/json' ,
206
+ 'Content-Type' : 'application/json' ,
207
+ Cache : 'no-cache' ,
208
+ 'X-Custom-Header' : 'foo' ,
209
+ } ,
210
+ } ) ;
211
+ /* eslint-disable */
212
+ fetch ( request ) . then ( ( ) => {
213
+ // @ts -expect-error Sentry is a global
214
+ Sentry . captureException ( 'test error' ) ;
215
+ } ) ;
216
+ /* eslint-enable */
217
+ } ) ,
218
+ requestPromise ,
219
+ replayRequestPromise ,
220
+ ] ) ;
215
221
216
- const request = await requestPromise ;
217
222
const eventData = envelopeRequestParser ( request ) ;
218
223
219
224
expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
@@ -230,7 +235,6 @@ sentryTest('captures request headers on Request', async ({ getLocalTestPath, pag
230
235
} ,
231
236
} ) ;
232
237
233
- const { replayRecordingSnapshots } = await replayRequestPromise ;
234
238
expect ( getReplayPerformanceSpans ( replayRecordingSnapshots ) . filter ( span => span . op === 'resource.fetch' ) ) . toEqual ( [
235
239
{
236
240
data : {
@@ -280,25 +284,28 @@ sentryTest('captures request headers as Headers instance', async ({ getLocalTest
280
284
281
285
await page . goto ( url ) ;
282
286
283
- await page . evaluate ( ( ) => {
284
- const headers = new Headers ( ) ;
285
- headers . append ( 'Accept' , 'application/json' ) ;
286
- headers . append ( 'Content-Type' , 'application/json' ) ;
287
- headers . append ( 'Cache' , 'no-cache' ) ;
288
- headers . append ( 'X-Custom-Header' , 'foo' ) ;
287
+ const [ , request , { replayRecordingSnapshots } ] = await Promise . all ( [
288
+ page . evaluate ( ( ) => {
289
+ const headers = new Headers ( ) ;
290
+ headers . append ( 'Accept' , 'application/json' ) ;
291
+ headers . append ( 'Content-Type' , 'application/json' ) ;
292
+ headers . append ( 'Cache' , 'no-cache' ) ;
293
+ headers . append ( 'X-Custom-Header' , 'foo' ) ;
289
294
290
- /* eslint-disable */
291
- fetch ( 'http://localhost:7654/foo' , {
292
- method : 'POST' ,
293
- headers,
294
- } ) . then ( ( ) => {
295
- // @ts -expect-error Sentry is a global
296
- Sentry . captureException ( 'test error' ) ;
297
- } ) ;
298
- /* eslint-enable */
299
- } ) ;
295
+ /* eslint-disable */
296
+ fetch ( 'http://localhost:7654/foo' , {
297
+ method : 'POST' ,
298
+ headers,
299
+ } ) . then ( ( ) => {
300
+ // @ts -expect-error Sentry is a global
301
+ Sentry . captureException ( 'test error' ) ;
302
+ } ) ;
303
+ /* eslint-enable */
304
+ } ) ,
305
+ requestPromise ,
306
+ replayRequestPromise ,
307
+ ] ) ;
300
308
301
- const request = await requestPromise ;
302
309
const eventData = envelopeRequestParser ( request ) ;
303
310
304
311
expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
@@ -315,7 +322,6 @@ sentryTest('captures request headers as Headers instance', async ({ getLocalTest
315
322
} ,
316
323
} ) ;
317
324
318
- const { replayRecordingSnapshots } = await replayRequestPromise ;
319
325
expect ( getReplayPerformanceSpans ( replayRecordingSnapshots ) . filter ( span => span . op === 'resource.fetch' ) ) . toEqual ( [
320
326
{
321
327
data : {
@@ -364,25 +370,28 @@ sentryTest('does not captures request headers if URL does not match', async ({ g
364
370
const url = await getLocalTestPath ( { testDir : __dirname } ) ;
365
371
await page . goto ( url ) ;
366
372
367
- await page . evaluate ( ( ) => {
368
- /* eslint-disable */
369
- fetch ( 'http://localhost:7654/bar' , {
370
- method : 'POST' ,
371
- headers : {
372
- Accept : 'application/json' ,
373
- 'Content-Type' : 'application/json' ,
374
- Cache : 'no-cache' ,
375
- 'X-Custom-Header' : 'foo' ,
376
- 'X-Test-Header' : 'test-value' ,
377
- } ,
378
- } ) . then ( ( ) => {
379
- // @ts -expect-error Sentry is a global
380
- Sentry . captureException ( 'test error' ) ;
381
- } ) ;
382
- /* eslint-enable */
383
- } ) ;
373
+ const [ , request , { replayRecordingSnapshots } ] = await Promise . all ( [
374
+ page . evaluate ( ( ) => {
375
+ /* eslint-disable */
376
+ fetch ( 'http://localhost:7654/bar' , {
377
+ method : 'POST' ,
378
+ headers : {
379
+ Accept : 'application/json' ,
380
+ 'Content-Type' : 'application/json' ,
381
+ Cache : 'no-cache' ,
382
+ 'X-Custom-Header' : 'foo' ,
383
+ 'X-Test-Header' : 'test-value' ,
384
+ } ,
385
+ } ) . then ( ( ) => {
386
+ // @ts -expect-error Sentry is a global
387
+ Sentry . captureException ( 'test error' ) ;
388
+ } ) ;
389
+ /* eslint-enable */
390
+ } ) ,
391
+ requestPromise ,
392
+ replayRequestPromise ,
393
+ ] ) ;
384
394
385
- const request = await requestPromise ;
386
395
const eventData = envelopeRequestParser ( request ) ;
387
396
388
397
expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
@@ -399,7 +408,6 @@ sentryTest('does not captures request headers if URL does not match', async ({ g
399
408
} ,
400
409
} ) ;
401
410
402
- const { replayRecordingSnapshots } = await replayRequestPromise ;
403
411
expect ( getReplayPerformanceSpans ( replayRecordingSnapshots ) . filter ( span => span . op === 'resource.fetch' ) ) . toEqual ( [
404
412
{
405
413
data : {
0 commit comments