Skip to content

Commit b10e550

Browse files
committed
test(replay): Potentially fix flaky xhr/fetch request tests
change order of actions and awaiting requests use Promise.all in xhr test reduce flush mindelay, increase maxdelay explicitly await request response simplify waitForResponse skip tests on firefox cleanup test
1 parent 3324324 commit b10e550

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

packages/integration-tests/suites/replay/requests/init.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import * as Sentry from '@sentry/browser';
22

33
window.Sentry = Sentry;
44
window.Replay = new Sentry.Replay({
5-
flushMinDelay: 500,
6-
flushMaxDelay: 500,
7-
useCompression: true,
5+
flushMinDelay: 200,
6+
flushMaxDelay: 2000,
7+
useCompression: false,
88
});
99

1010
Sentry.init({

packages/integration-tests/suites/replay/requests/test.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import { sentryTest } from '../../../utils/fixtures';
44
import { expectedFetchPerformanceSpan, expectedXHRPerformanceSpan } from '../../../utils/replayEventTemplates';
55
import { getReplayRecordingContent, shouldSkipReplayTest, waitForReplayRequest } from '../../../utils/replayHelpers';
66

7-
sentryTest('replay recording should contain fetch request span', async ({ getLocalTestPath, page }) => {
8-
if (shouldSkipReplayTest()) {
7+
sentryTest('replay recording should contain fetch request span', async ({ getLocalTestPath, page, browserName }) => {
8+
// For some reason, observing and waiting for requests in firefox is extremely flaky.
9+
// We therefore skip this test for firefox and only test on chromium/webkit.
10+
// Possibly related: https://github.com/microsoft/playwright/issues/11390
11+
if (shouldSkipReplayTest() || browserName === 'firefox') {
912
sentryTest.skip();
1013
}
1114

@@ -31,18 +34,23 @@ sentryTest('replay recording should contain fetch request span', async ({ getLoc
3134
const url = await getLocalTestPath({ testDir: __dirname });
3235

3336
await page.goto(url);
34-
await page.click('#fetch');
3537
await page.click('#go-background');
36-
3738
const { performanceSpans: spans0 } = getReplayRecordingContent(await reqPromise0);
39+
40+
const receivedResponse = page.waitForResponse('https://example.com');
41+
await page.click('#fetch');
42+
await receivedResponse;
43+
3844
const { performanceSpans: spans1 } = getReplayRecordingContent(await reqPromise1);
39-
const performanceSpans = [...spans0, ...spans1];
4045

46+
const performanceSpans = [...spans0, ...spans1];
4147
expect(performanceSpans).toContainEqual(expectedFetchPerformanceSpan);
4248
});
4349

44-
sentryTest('replay recording should contain XHR request span', async ({ getLocalTestPath, page }) => {
45-
if (shouldSkipReplayTest()) {
50+
sentryTest('replay recording should contain XHR request span', async ({ getLocalTestPath, page, browserName }) => {
51+
// For some reason, observing and waiting for requests in firefox is extremely flaky.
52+
// We therefore skip this test for firefox and only test on chromium/webkit.
53+
if (shouldSkipReplayTest() || browserName === 'firefox') {
4654
sentryTest.skip();
4755
}
4856

@@ -68,11 +76,15 @@ sentryTest('replay recording should contain XHR request span', async ({ getLocal
6876
const url = await getLocalTestPath({ testDir: __dirname });
6977

7078
await page.goto(url);
71-
await page.click('#xhr');
7279
await page.click('#go-background');
73-
7480
const { performanceSpans: spans0 } = getReplayRecordingContent(await reqPromise0);
81+
82+
const receivedResponse = page.waitForResponse('https://example.com');
83+
await page.click('#xhr');
84+
await receivedResponse;
85+
7586
const { performanceSpans: spans1 } = getReplayRecordingContent(await reqPromise1);
87+
7688
const performanceSpans = [...spans0, ...spans1];
7789

7890
expect(performanceSpans).toContainEqual(expectedXHRPerformanceSpan);

0 commit comments

Comments
 (0)