File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -2207,18 +2207,24 @@ describe('Client', () => {
22072207 } ) ;
22082208
22092209 test ( 'flush returns immediately when nothing is processing' , async ( ) => {
2210- vi . useRealTimers ( ) ;
2210+ vi . useFakeTimers ( ) ;
22112211 expect . assertions ( 2 ) ;
22122212
22132213 const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
22142214 const client = new TestClient ( options ) ;
22152215
2216- const startTime = Date . now ( ) ;
2217- const result = await client . flush ( 1000 ) ;
2218- const elapsed = Date . now ( ) - startTime ;
2216+ // just to ensure the client init'd
2217+ vi . advanceTimersByTime ( 100 ) ;
2218+
2219+ const elapsed = Date . now ( ) ;
2220+ const done = client . flush ( 1000 ) . then ( result => {
2221+ expect ( result ) . toBe ( true ) ;
2222+ expect ( Date . now ( ) - elapsed ) . toBeLessThan ( 2 ) ;
2223+ } ) ;
22192224
2220- expect ( result ) . toBe ( true ) ;
2221- expect ( elapsed ) . toBeLessThan ( 100 ) ;
2225+ // ensures that only after 1 ms, we're already done flushing
2226+ vi . advanceTimersByTime ( 1 ) ;
2227+ await done ;
22222228 } ) ;
22232229
22242230 test ( 'flush with early exit when processing completes' , async ( ) => {
You can’t perform that action at this time.
0 commit comments