Skip to content

Commit 7e60dc8

Browse files
committed
fix flakyness..??
1 parent f7f483f commit 7e60dc8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/browser-integration-tests/suites/replay/dsc/test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { EventEnvelopeHeaders } from '@sentry/types';
33

44
import { sentryTest } from '../../../utils/fixtures';
55
import { envelopeHeaderRequestParser, getFirstSentryEnvelopeRequest } from '../../../utils/helpers';
6-
import { getReplaySnapshot, shouldSkipReplayTest } from '../../../utils/replayHelpers';
6+
import { getReplaySnapshot, shouldSkipReplayTest, waitForReplayRunning } from '../../../utils/replayHelpers';
77

88
sentryTest('should add replay_id to dsc of transactions', async ({ getLocalTestPath, page }) => {
99
if (shouldSkipReplayTest()) {
@@ -15,6 +15,7 @@ sentryTest('should add replay_id to dsc of transactions', async ({ getLocalTestP
1515

1616
const envHeader = await getFirstSentryEnvelopeRequest<EventEnvelopeHeaders>(page, url, envelopeHeaderRequestParser);
1717

18+
await waitForReplayRunning(page);
1819
const replay = await getReplaySnapshot(page);
1920

2021
expect(replay.session?.id).toBeDefined();

packages/browser-integration-tests/utils/replayHelpers.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ function isCustomSnapshot(event: RecordingEvent): event is RecordingEvent & { da
9999
return event.type === EventType.Custom;
100100
}
101101

102+
/** Wait for replay to be running & available. */
103+
export async function waitForReplayRunning(page: Page): Promise<void> {
104+
await page.waitForFunction(() => {
105+
const replayIntegration = (window as unknown as Window & { Replay: { _replay: ReplayContainer } }).Replay;
106+
const replay = replayIntegration._replay;
107+
108+
return replay.isEnabled() && replay.session?.id !== undefined;
109+
});
110+
}
111+
102112
/**
103113
* This returns the replay container (assuming it exists).
104114
* Note that due to how this works with playwright, this is a POJO copy of replay.

0 commit comments

Comments
 (0)