Skip to content

Commit

Permalink
fix flakyness..??
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Mar 23, 2023
1 parent f7f483f commit 7e60dc8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/browser-integration-tests/suites/replay/dsc/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { EventEnvelopeHeaders } from '@sentry/types';

import { sentryTest } from '../../../utils/fixtures';
import { envelopeHeaderRequestParser, getFirstSentryEnvelopeRequest } from '../../../utils/helpers';
import { getReplaySnapshot, shouldSkipReplayTest } from '../../../utils/replayHelpers';
import { getReplaySnapshot, shouldSkipReplayTest, waitForReplayRunning } from '../../../utils/replayHelpers';

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

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

await waitForReplayRunning(page);
const replay = await getReplaySnapshot(page);

expect(replay.session?.id).toBeDefined();
Expand Down
10 changes: 10 additions & 0 deletions packages/browser-integration-tests/utils/replayHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ function isCustomSnapshot(event: RecordingEvent): event is RecordingEvent & { da
return event.type === EventType.Custom;
}

/** Wait for replay to be running & available. */
export async function waitForReplayRunning(page: Page): Promise<void> {
await page.waitForFunction(() => {
const replayIntegration = (window as unknown as Window & { Replay: { _replay: ReplayContainer } }).Replay;
const replay = replayIntegration._replay;

return replay.isEnabled() && replay.session?.id !== undefined;
});
}

/**
* This returns the replay container (assuming it exists).
* Note that due to how this works with playwright, this is a POJO copy of replay.
Expand Down

0 comments on commit 7e60dc8

Please sign in to comment.