Skip to content

Commit ffeca25

Browse files
committed
use force flush test util
1 parent dfc185f commit ffeca25

File tree

3 files changed

+33
-32
lines changed
  • packages/integration-tests/suites/replay/errors

3 files changed

+33
-32
lines changed

packages/integration-tests/suites/replay/errors/droppedError/test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getReplaySnapshot, shouldSkipReplayTest } from '../../../../utils/repla
55

66
sentryTest(
77
'[error-mode] should not start recording if an error occurred when the error was dropped',
8-
async ({ getLocalTestPath, page }) => {
8+
async ({ getLocalTestPath, page, forceFlushReplay }) => {
99
if (shouldSkipReplayTest()) {
1010
sentryTest.skip();
1111
}
@@ -25,14 +25,13 @@ sentryTest(
2525
const url = await getLocalTestPath({ testDir: __dirname });
2626

2727
await page.goto(url);
28-
await page.click('#go-background');
28+
await forceFlushReplay();
2929
expect(callsToSentry).toEqual(0);
3030

3131
await page.click('#error');
3232

33-
await page.click('#go-background');
3433
await page.click('#log');
35-
await page.click('#go-background');
34+
await forceFlushReplay();
3635

3736
expect(callsToSentry).toEqual(0);
3837

packages/integration-tests/suites/replay/errors/errorModeCustomTransport/test.ts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,40 @@ import { expect } from '@playwright/test';
33
import { sentryTest } from '../../../../utils/fixtures';
44
import { getReplaySnapshot, shouldSkipReplayTest, waitForReplayRequest } from '../../../../utils/replayHelpers';
55

6-
sentryTest('[error-mode] should handle errors with custom transport', async ({ getLocalTestPath, page }) => {
7-
if (shouldSkipReplayTest()) {
8-
sentryTest.skip();
9-
}
6+
sentryTest(
7+
'[error-mode] should handle errors with custom transport',
8+
async ({ getLocalTestPath, page, forceFlushReplay }) => {
9+
if (shouldSkipReplayTest()) {
10+
sentryTest.skip();
11+
}
1012

11-
const promiseReq0 = waitForReplayRequest(page, 0);
12-
const promiseReq1 = waitForReplayRequest(page, 1);
13+
const promiseReq0 = waitForReplayRequest(page, 0);
14+
const promiseReq1 = waitForReplayRequest(page, 1);
1315

14-
let callsToSentry = 0;
16+
let callsToSentry = 0;
1517

16-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
17-
callsToSentry++;
18+
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
19+
callsToSentry++;
1820

19-
return route.fulfill({
20-
// Only error out for error, then succeed
21-
status: callsToSentry === 1 ? 422 : 200,
21+
return route.fulfill({
22+
// Only error out for error, then succeed
23+
status: callsToSentry === 1 ? 422 : 200,
24+
});
2225
});
23-
});
2426

25-
const url = await getLocalTestPath({ testDir: __dirname });
27+
const url = await getLocalTestPath({ testDir: __dirname });
2628

27-
await page.goto(url);
28-
await page.click('#go-background');
29-
expect(callsToSentry).toEqual(0);
29+
await page.goto(url);
30+
await forceFlushReplay();
31+
expect(callsToSentry).toEqual(0);
3032

31-
await page.click('#error');
32-
await promiseReq0;
33+
await page.click('#error');
34+
await promiseReq0;
3335

34-
await page.click('#go-background');
35-
await promiseReq1;
36+
await forceFlushReplay();
37+
await promiseReq1;
3638

37-
const replay = await getReplaySnapshot(page);
38-
expect(replay.recordingMode).toBe('session');
39-
});
39+
const replay = await getReplaySnapshot(page);
40+
expect(replay.recordingMode).toBe('session');
41+
},
42+
);

packages/integration-tests/suites/replay/errors/errorNotSent/test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getReplaySnapshot, shouldSkipReplayTest } from '../../../../utils/repla
55

66
sentryTest(
77
'[error-mode] should handle errors that result in API error response',
8-
async ({ getLocalTestPath, page }) => {
8+
async ({ getLocalTestPath, page, forceFlushReplay }) => {
99
if (shouldSkipReplayTest()) {
1010
sentryTest.skip();
1111
}
@@ -24,14 +24,13 @@ sentryTest(
2424
const url = await getLocalTestPath({ testDir: __dirname });
2525

2626
await page.goto(url);
27-
await page.click('#go-background');
27+
await forceFlushReplay();
2828
expect(callsToSentry).toEqual(0);
2929

3030
await page.click('#error');
3131

32-
await page.click('#go-background');
3332
await page.click('#log');
34-
await page.click('#go-background');
33+
await forceFlushReplay();
3534

3635
// Only sent once, but since API failed we do not go into session mode
3736
expect(callsToSentry).toEqual(1);

0 commit comments

Comments
 (0)