File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ jest.mock("../../src/telemetry/eventCache.js");
1717const MockEventCache = EventCache as jest . MockedClass < typeof EventCache > ;
1818
1919const nextTick = ( ) => new Promise ( ( resolve ) => process . nextTick ( resolve ) ) ;
20+ const delay = ( ms : number ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
2021
2122describe ( "Telemetry" , ( ) => {
2223 const machineId = "test-machine-id" ;
@@ -270,7 +271,7 @@ describe("Telemetry", () => {
270271 ) ;
271272 } ) ;
272273
273- it ( "should timeout if machine ID resolution takes too long" , ( ) => {
274+ it ( "should timeout if machine ID resolution takes too long" , async ( ) => {
274275 const loggerSpy = jest . spyOn ( logger , "debug" ) ;
275276
276277 telemetry = Telemetry . create ( session , config , {
@@ -282,9 +283,9 @@ describe("Telemetry", () => {
282283
283284 telemetry . emitEvents ( [ testEvent ] ) ;
284285
285- jest . advanceTimersByTime ( 5000 ) ; // Wait for timeout
286+ await delay ( 5000 ) ; // Wait for timeout
286287
287- expect ( loggerSpy ) . not . toHaveBeenNthCalledWith (
288+ expect ( loggerSpy ) . toHaveBeenNthCalledWith (
288289 2 ,
289290 LogId . telemetryDeviceIdTimeout ,
290291 "telemetry" ,
You can’t perform that action at this time.
0 commit comments