Skip to content

Commit e8c523d

Browse files
authored
test(integration): Fix flakey test replay/extendNetworkBreadcrumbs/xhr/captureRequestSize (#10777)
[maybe] fixes this flakey test
1 parent 240fd8a commit e8c523d

File tree

1 file changed

+18
-16
lines changed
  • dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestSize

1 file changed

+18
-16
lines changed

dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestSize/test.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,25 @@ sentryTest('captures request body size when body is sent', async ({ getLocalTest
3636
const url = await getLocalTestPath({ testDir: __dirname });
3737
await page.goto(url);
3838

39-
void page.evaluate(() => {
40-
/* eslint-disable */
41-
const xhr = new XMLHttpRequest();
42-
43-
xhr.open('POST', 'http://localhost:7654/foo');
44-
xhr.send('{"foo":"bar"}');
45-
46-
xhr.addEventListener('readystatechange', function () {
47-
if (xhr.readyState === 4) {
48-
// @ts-expect-error Sentry is a global
49-
setTimeout(() => Sentry.captureException('test error', 0));
50-
}
51-
});
52-
/* eslint-enable */
53-
});
39+
const [, request] = await Promise.all([
40+
page.evaluate(() => {
41+
/* eslint-disable */
42+
const xhr = new XMLHttpRequest();
43+
44+
xhr.open('POST', 'http://localhost:7654/foo');
45+
xhr.send('{"foo":"bar"}');
46+
47+
xhr.addEventListener('readystatechange', function () {
48+
if (xhr.readyState === 4) {
49+
// @ts-expect-error Sentry is a global
50+
setTimeout(() => Sentry.captureException('test error', 0));
51+
}
52+
});
53+
/* eslint-enable */
54+
}),
55+
requestPromise,
56+
]);
5457

55-
const request = await requestPromise;
5658
const eventData = envelopeRequestParser(request);
5759

5860
expect(eventData.exception?.values).toHaveLength(1);

0 commit comments

Comments
 (0)