diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts index bcbfa1890cdd..e1aca233ecf2 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts @@ -1,8 +1,10 @@ import { expect } from '@playwright/test'; -import type { Event } from '@sentry/core'; - import { sentryTest } from '../../../../utils/fixtures'; -import { getMultipleSentryEnvelopeRequests, shouldSkipTracingTest } from '../../../../utils/helpers'; +import { + envelopeRequestParser, + shouldSkipTracingTest, + waitForTransactionRequestOnUrl, +} from '../../../../utils/helpers'; sentryTest('should create spans for fetch requests', async ({ getLocalTestUrl, page }) => { if (shouldSkipTracingTest()) { @@ -11,14 +13,8 @@ sentryTest('should create spans for fetch requests', async ({ getLocalTestUrl, p const url = await getLocalTestUrl({ testDir: __dirname }); - // Because we fetch from http://example.com, fetch will throw a CORS error in firefox and webkit. - // Chromium does not throw for cors errors. - // This means that we will intercept a dynamic amount of envelopes here. - - // We will wait 500ms for all envelopes to be sent. Generally, in all browsers, the last sent - // envelope contains tracing data. - const envelopes = await getMultipleSentryEnvelopeRequests(page, 4, { url, timeout: 10000 }); - const tracingEvent = envelopes.find(event => event.type === 'transaction')!; // last envelope contains tracing data on all browsers + const req = await waitForTransactionRequestOnUrl(page, url); + const tracingEvent = envelopeRequestParser(req); const requestSpans = tracingEvent.spans?.filter(({ op }) => op === 'http.client'); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/init.js b/dev-packages/browser-integration-tests/suites/tracing/request/init.js index 7cd076a052e5..092c43f75eac 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/init.js +++ b/dev-packages/browser-integration-tests/suites/tracing/request/init.js @@ -7,4 +7,5 @@ Sentry.init({ integrations: [Sentry.browserTracingIntegration()], tracePropagationTargets: ['http://example.com'], tracesSampleRate: 1, + autoSessionTracking: false, });