@@ -35,7 +35,7 @@ sentryTest('handles empty/missing request headers', async ({ getLocalTestPath, p
3535 const url = await getLocalTestPath ( { testDir : __dirname } ) ;
3636 await page . goto ( url ) ;
3737
38- const [ , request ] = await Promise . all ( [
38+ const [ , request , { replayRecordingSnapshots } ] = await Promise . all ( [
3939 page . evaluate ( ( ) => {
4040 /* eslint-disable */
4141 fetch ( 'http://localhost:7654/foo' , {
@@ -47,6 +47,7 @@ sentryTest('handles empty/missing request headers', async ({ getLocalTestPath, p
4747 /* eslint-enable */
4848 } ) ,
4949 requestPromise ,
50+ replayRequestPromise ,
5051 ] ) ;
5152
5253 const eventData = envelopeRequestParser ( request ) ;
@@ -65,7 +66,6 @@ sentryTest('handles empty/missing request headers', async ({ getLocalTestPath, p
6566 } ,
6667 } ) ;
6768
68- const { replayRecordingSnapshots } = await replayRequestPromise ;
6969 expect ( getReplayPerformanceSpans ( replayRecordingSnapshots ) . filter ( span => span . op === 'resource.fetch' ) ) . toEqual ( [
7070 {
7171 data : {
@@ -110,7 +110,7 @@ sentryTest('captures request headers as POJO', async ({ getLocalTestPath, page,
110110 const url = await getLocalTestPath ( { testDir : __dirname } ) ;
111111 await page . goto ( url ) ;
112112
113- const [ , request ] = await Promise . all ( [
113+ const [ , request , { replayRecordingSnapshots } ] = await Promise . all ( [
114114 page . evaluate ( ( ) => {
115115 /* eslint-disable */
116116 fetch ( 'http://localhost:7654/foo' , {
@@ -129,6 +129,7 @@ sentryTest('captures request headers as POJO', async ({ getLocalTestPath, page,
129129 /* eslint-enable */
130130 } ) ,
131131 requestPromise ,
132+ replayRequestPromise ,
132133 ] ) ;
133134
134135 const eventData = envelopeRequestParser ( request ) ;
@@ -147,7 +148,6 @@ sentryTest('captures request headers as POJO', async ({ getLocalTestPath, page,
147148 } ,
148149 } ) ;
149150
150- const { replayRecordingSnapshots } = await replayRequestPromise ;
151151 expect ( getReplayPerformanceSpans ( replayRecordingSnapshots ) . filter ( span => span . op === 'resource.fetch' ) ) . toEqual ( [
152152 {
153153 data : {
@@ -197,25 +197,28 @@ sentryTest('captures request headers on Request', async ({ getLocalTestPath, pag
197197 const url = await getLocalTestPath ( { testDir : __dirname } ) ;
198198 await page . goto ( url ) ;
199199
200- await page . evaluate ( ( ) => {
201- const request = new Request ( 'http://localhost:7654/foo' , {
202- method : 'POST' ,
203- headers : {
204- Accept : 'application/json' ,
205- 'Content-Type' : 'application/json' ,
206- Cache : 'no-cache' ,
207- 'X-Custom-Header' : 'foo' ,
208- } ,
209- } ) ;
210- /* eslint-disable */
211- fetch ( request ) . then ( ( ) => {
212- // @ts -expect-error Sentry is a global
213- Sentry . captureException ( 'test error' ) ;
214- } ) ;
215- /* eslint-enable */
216- } ) ;
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+ ] ) ;
217221
218- const request = await requestPromise ;
219222 const eventData = envelopeRequestParser ( request ) ;
220223
221224 expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
@@ -232,7 +235,6 @@ sentryTest('captures request headers on Request', async ({ getLocalTestPath, pag
232235 } ,
233236 } ) ;
234237
235- const { replayRecordingSnapshots } = await replayRequestPromise ;
236238 expect ( getReplayPerformanceSpans ( replayRecordingSnapshots ) . filter ( span => span . op === 'resource.fetch' ) ) . toEqual ( [
237239 {
238240 data : {
@@ -282,25 +284,28 @@ sentryTest('captures request headers as Headers instance', async ({ getLocalTest
282284
283285 await page . goto ( url ) ;
284286
285- await page . evaluate ( ( ) => {
286- const headers = new Headers ( ) ;
287- headers . append ( 'Accept' , 'application/json' ) ;
288- headers . append ( 'Content-Type' , 'application/json' ) ;
289- headers . append ( 'Cache' , 'no-cache' ) ;
290- 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' ) ;
291294
292- /* eslint-disable */
293- fetch ( 'http://localhost:7654/foo' , {
294- method : 'POST' ,
295- headers,
296- } ) . then ( ( ) => {
297- // @ts -expect-error Sentry is a global
298- Sentry . captureException ( 'test error' ) ;
299- } ) ;
300- /* eslint-enable */
301- } ) ;
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+ ] ) ;
302308
303- const request = await requestPromise ;
304309 const eventData = envelopeRequestParser ( request ) ;
305310
306311 expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
@@ -317,7 +322,6 @@ sentryTest('captures request headers as Headers instance', async ({ getLocalTest
317322 } ,
318323 } ) ;
319324
320- const { replayRecordingSnapshots } = await replayRequestPromise ;
321325 expect ( getReplayPerformanceSpans ( replayRecordingSnapshots ) . filter ( span => span . op === 'resource.fetch' ) ) . toEqual ( [
322326 {
323327 data : {
@@ -366,7 +370,7 @@ sentryTest('does not captures request headers if URL does not match', async ({ g
366370 const url = await getLocalTestPath ( { testDir : __dirname } ) ;
367371 await page . goto ( url ) ;
368372
369- const [ , request ] = await Promise . all ( [
373+ const [ , request , { replayRecordingSnapshots } ] = await Promise . all ( [
370374 page . evaluate ( ( ) => {
371375 /* eslint-disable */
372376 fetch ( 'http://localhost:7654/bar' , {
@@ -385,6 +389,7 @@ sentryTest('does not captures request headers if URL does not match', async ({ g
385389 /* eslint-enable */
386390 } ) ,
387391 requestPromise ,
392+ replayRequestPromise ,
388393 ] ) ;
389394
390395 const eventData = envelopeRequestParser ( request ) ;
@@ -403,7 +408,6 @@ sentryTest('does not captures request headers if URL does not match', async ({ g
403408 } ,
404409 } ) ;
405410
406- const { replayRecordingSnapshots } = await replayRequestPromise ;
407411 expect ( getReplayPerformanceSpans ( replayRecordingSnapshots ) . filter ( span => span . op === 'resource.fetch' ) ) . toEqual ( [
408412 {
409413 data : {
0 commit comments