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");
17
17
const MockEventCache = EventCache as jest . MockedClass < typeof EventCache > ;
18
18
19
19
const nextTick = ( ) => new Promise ( ( resolve ) => process . nextTick ( resolve ) ) ;
20
+ const delay = ( ms : number ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
20
21
21
22
describe ( "Telemetry" , ( ) => {
22
23
const machineId = "test-machine-id" ;
@@ -270,7 +271,7 @@ describe("Telemetry", () => {
270
271
) ;
271
272
} ) ;
272
273
273
- it ( "should timeout if machine ID resolution takes too long" , ( ) => {
274
+ it ( "should timeout if machine ID resolution takes too long" , async ( ) => {
274
275
const loggerSpy = jest . spyOn ( logger , "debug" ) ;
275
276
276
277
telemetry = Telemetry . create ( session , config , {
@@ -282,9 +283,9 @@ describe("Telemetry", () => {
282
283
283
284
telemetry . emitEvents ( [ testEvent ] ) ;
284
285
285
- jest . advanceTimersByTime ( 5000 ) ; // Wait for timeout
286
+ await delay ( 5000 ) ; // Wait for timeout
286
287
287
- expect ( loggerSpy ) . not . toHaveBeenNthCalledWith (
288
+ expect ( loggerSpy ) . toHaveBeenNthCalledWith (
288
289
2 ,
289
290
LogId . telemetryDeviceIdTimeout ,
290
291
"telemetry" ,
You can’t perform that action at this time.
0 commit comments