@@ -80,6 +80,8 @@ describe('Integration | errorSampleRate', () => {
80
80
81
81
captureException ( new Error ( 'testing' ) ) ;
82
82
83
+ await vi . advanceTimersToNextTimerAsync ( ) ;
84
+ // need 2nd tick to wait for `saveSession` to complete in `handleGlobalEvents
83
85
await vi . advanceTimersToNextTimerAsync ( ) ;
84
86
85
87
expect ( replay ) . toHaveLastSentReplay ( {
@@ -158,6 +160,7 @@ describe('Integration | errorSampleRate', () => {
158
160
segmentId : 0 ,
159
161
sampled : 'buffer' ,
160
162
previousSessionId : 'previoussessionid' ,
163
+ dirty : false ,
161
164
} ) ,
162
165
} ) ) ;
163
166
@@ -179,6 +182,8 @@ describe('Integration | errorSampleRate', () => {
179
182
180
183
captureException ( new Error ( 'testing' ) ) ;
181
184
await vi . advanceTimersToNextTimerAsync ( ) ;
185
+ // need 2nd tick to wait for `saveSession` to complete in `handleGlobalEvents
186
+ await vi . advanceTimersToNextTimerAsync ( ) ;
182
187
183
188
// Converts to session mode
184
189
expect ( replay . recordingMode ) . toBe ( 'session' ) ;
@@ -508,6 +513,8 @@ describe('Integration | errorSampleRate', () => {
508
513
509
514
captureException ( new Error ( 'testing' ) ) ;
510
515
516
+ await vi . advanceTimersToNextTimerAsync ( ) ;
517
+ // need 2nd tick to wait for `saveSession` to complete in `handleGlobalEvents
511
518
await vi . advanceTimersToNextTimerAsync ( ) ;
512
519
513
520
expect ( replay ) . toHaveLastSentReplay ( {
@@ -604,6 +611,8 @@ describe('Integration | errorSampleRate', () => {
604
611
// should still react to errors later on
605
612
captureException ( new Error ( 'testing' ) ) ;
606
613
614
+ await vi . advanceTimersToNextTimerAsync ( ) ;
615
+ // need 2nd tick to wait for `saveSession` to complete in `handleGlobalEvents
607
616
await vi . advanceTimersToNextTimerAsync ( ) ;
608
617
609
618
expect ( replay . session ?. id ) . toBe ( oldSessionId ) ;
@@ -739,7 +748,8 @@ describe('Integration | errorSampleRate', () => {
739
748
captureException ( new Error ( 'testing' ) ) ;
740
749
741
750
await vi . advanceTimersToNextTimerAsync ( ) ;
742
- // await vi.advanceTimersToNextTimerAsync();
751
+ // need 2nd tick to wait for `saveSession` to complete in `handleGlobalEvents
752
+ await vi . advanceTimersToNextTimerAsync ( ) ;
743
753
744
754
// This is still the timestamp from the full snapshot we took earlier
745
755
expect ( replay . session ?. started ) . toBe ( BASE_TIMESTAMP + ELAPSED ) ;
0 commit comments