Skip to content

Commit 40d9b9f

Browse files
Lms24mydea
andauthored
test(v8/browser): Unflake browser request test (#15055)
Backport of #15050 Co-authored-by: Francesco Gringl-Novy <[email protected]>
1 parent 9ccf2bf commit 40d9b9f

File tree

2 files changed

+8
-11
lines changed
  • dev-packages/browser-integration-tests/suites/tracing/request

2 files changed

+8
-11
lines changed

dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { expect } from '@playwright/test';
2-
import type { Event } from '@sentry/core';
3-
42
import { sentryTest } from '../../../../utils/fixtures';
5-
import { getMultipleSentryEnvelopeRequests, shouldSkipTracingTest } from '../../../../utils/helpers';
3+
import {
4+
envelopeRequestParser,
5+
shouldSkipTracingTest,
6+
waitForTransactionRequestOnUrl,
7+
} from '../../../../utils/helpers';
68

79
sentryTest('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

dev-packages/browser-integration-tests/suites/tracing/request/init.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ Sentry.init({
77
integrations: [Sentry.browserTracingIntegration()],
88
tracePropagationTargets: ['http://example.com'],
99
tracesSampleRate: 1,
10+
autoSessionTracking: false,
1011
});

0 commit comments

Comments
 (0)