Skip to content

Commit 46cbaf2

Browse files
committed
fix tests
1 parent 2ab84b6 commit 46cbaf2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/replay-internal/test/integration/errorSampleRate.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ describe('Integration | errorSampleRate', () => {
8080

8181
captureException(new Error('testing'));
8282

83+
await vi.advanceTimersToNextTimerAsync();
84+
// need 2nd tick to wait for `saveSession` to complete in `handleGlobalEvents
8385
await vi.advanceTimersToNextTimerAsync();
8486

8587
expect(replay).toHaveLastSentReplay({
@@ -158,6 +160,7 @@ describe('Integration | errorSampleRate', () => {
158160
segmentId: 0,
159161
sampled: 'buffer',
160162
previousSessionId: 'previoussessionid',
163+
dirty: false,
161164
}),
162165
}));
163166

@@ -179,6 +182,8 @@ describe('Integration | errorSampleRate', () => {
179182

180183
captureException(new Error('testing'));
181184
await vi.advanceTimersToNextTimerAsync();
185+
// need 2nd tick to wait for `saveSession` to complete in `handleGlobalEvents
186+
await vi.advanceTimersToNextTimerAsync();
182187

183188
// Converts to session mode
184189
expect(replay.recordingMode).toBe('session');
@@ -508,6 +513,8 @@ describe('Integration | errorSampleRate', () => {
508513

509514
captureException(new Error('testing'));
510515

516+
await vi.advanceTimersToNextTimerAsync();
517+
// need 2nd tick to wait for `saveSession` to complete in `handleGlobalEvents
511518
await vi.advanceTimersToNextTimerAsync();
512519

513520
expect(replay).toHaveLastSentReplay({
@@ -604,6 +611,8 @@ describe('Integration | errorSampleRate', () => {
604611
// should still react to errors later on
605612
captureException(new Error('testing'));
606613

614+
await vi.advanceTimersToNextTimerAsync();
615+
// need 2nd tick to wait for `saveSession` to complete in `handleGlobalEvents
607616
await vi.advanceTimersToNextTimerAsync();
608617

609618
expect(replay.session?.id).toBe(oldSessionId);
@@ -739,7 +748,8 @@ describe('Integration | errorSampleRate', () => {
739748
captureException(new Error('testing'));
740749

741750
await vi.advanceTimersToNextTimerAsync();
742-
// await vi.advanceTimersToNextTimerAsync();
751+
// need 2nd tick to wait for `saveSession` to complete in `handleGlobalEvents
752+
await vi.advanceTimersToNextTimerAsync();
743753

744754
// This is still the timestamp from the full snapshot we took earlier
745755
expect(replay.session?.started).toBe(BASE_TIMESTAMP + ELAPSED);

0 commit comments

Comments
 (0)