From ae93137f9cd177f5c49179884517d523b0a2b509 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 24 Jul 2026 18:11:09 +0200 Subject: [PATCH] test(browser): Unflake streamed XHR span assertions Streamed request spans are emitted in completion order, which is not deterministic for concurrent XHRs. Sort them by URL before asserting their expected contents. Co-Authored-By: Cursor Agent Co-authored-by: Cursor --- .../suites/tracing/request/xhr-streamed/test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-streamed/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-streamed/test.ts index 42ec27cb9674..a04daec4dc2f 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-streamed/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-streamed/test.ts @@ -19,7 +19,11 @@ sentryTest('creates spans for XHR requests', async ({ getLocalTestUrl, page }) = const allSpans = await spansPromise; const pageloadSpan = allSpans.find(s => getSpanOp(s) === 'pageload'); - const requestSpans = allSpans.filter(s => getSpanOp(s) === 'http.client'); + const requestSpans = allSpans + .filter(s => getSpanOp(s) === 'http.client') + .sort((a, b) => + (a.attributes!['http.url']!.value as string).localeCompare(b.attributes!['http.url']!.value as string), + ); expect(requestSpans).toHaveLength(3);