11import { expect } from '@playwright/test' ;
2- import type { Event } from '@sentry/core' ;
3-
42import { sentryTest } from '../../../../utils/fixtures' ;
5- import { getMultipleSentryEnvelopeRequests , shouldSkipTracingTest } from '../../../../utils/helpers' ;
3+ import {
4+ envelopeRequestParser ,
5+ shouldSkipTracingTest ,
6+ waitForTransactionRequestOnUrl ,
7+ } from '../../../../utils/helpers' ;
68
79sentryTest ( 'should create spans for fetch requests' , async ( { getLocalTestUrl, page } ) => {
810 if ( shouldSkipTracingTest ( ) ) {
@@ -11,14 +13,8 @@ sentryTest('should create spans for fetch requests', async ({ getLocalTestUrl, p
1113
1214 const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
1315
14- // Because we fetch from http://example.com, fetch will throw a CORS error in firefox and webkit.
15- // Chromium does not throw for cors errors.
16- // This means that we will intercept a dynamic amount of envelopes here.
17-
18- // We will wait 500ms for all envelopes to be sent. Generally, in all browsers, the last sent
19- // envelope contains tracing data.
20- const envelopes = await getMultipleSentryEnvelopeRequests < Event > ( page , 4 , { url, timeout : 10000 } ) ;
21- const tracingEvent = envelopes . find ( event => event . type === 'transaction' ) ! ; // last envelope contains tracing data on all browsers
16+ const req = await waitForTransactionRequestOnUrl ( page , url ) ;
17+ const tracingEvent = envelopeRequestParser ( req ) ;
2218
2319 const requestSpans = tracingEvent . spans ?. filter ( ( { op } ) => op === 'http.client' ) ;
2420
0 commit comments