@@ -4,6 +4,7 @@ import { Telemetry } from "../../src/telemetry/telemetry.js";
4
4
import { BaseEvent , TelemetryResult } from "../../src/telemetry/types.js" ;
5
5
import { EventCache } from "../../src/telemetry/eventCache.js" ;
6
6
import { config } from "../../src/config.js" ;
7
+ import { jest } from "@jest/globals" ;
7
8
8
9
// Mock the ApiClient to avoid real API calls
9
10
jest . mock ( "../../src/common/atlas/apiClient.js" ) ;
@@ -93,22 +94,29 @@ describe("Telemetry", () => {
93
94
94
95
// Setup mocked API client
95
96
mockApiClient = new MockApiClient ( { baseUrl : "" } ) as jest . Mocked < ApiClient > ;
96
- mockApiClient . sendEvents = jest . fn ( ) . mockResolvedValue ( undefined ) ;
97
- mockApiClient . hasCredentials = jest . fn ( ) . mockReturnValue ( true ) ;
97
+ //@ts -expect-error This is a workaround
98
+ mockApiClient . sendEvents = jest . fn < ( ) => undefined > ( ) . mockResolvedValue ( undefined ) ;
99
+ mockApiClient . hasCredentials = jest . fn < ( ) => boolean > ( ) . mockReturnValue ( true ) ;
98
100
99
101
// Setup mocked EventCache
100
102
mockEventCache = new MockEventCache ( ) as jest . Mocked < EventCache > ;
103
+ //@ts -expect-error This is a workaround
101
104
mockEventCache . getEvents = jest . fn ( ) . mockReturnValue ( [ ] ) ;
105
+ //@ts -expect-error This is a workaround
102
106
mockEventCache . clearEvents = jest . fn ( ) . mockResolvedValue ( undefined ) ;
107
+ //@ts -expect-error This is a workaround
103
108
mockEventCache . appendEvents = jest . fn ( ) . mockResolvedValue ( undefined ) ;
109
+ //@ts -expect-error This is a workaround
104
110
MockEventCache . getInstance = jest . fn ( ) . mockReturnValue ( mockEventCache ) ;
105
111
106
112
// Create a simplified session with our mocked API client
107
113
session = {
108
114
apiClient : mockApiClient ,
109
115
sessionId : "test-session-id" ,
110
116
agentRunner : { name : "test-agent" , version : "1.0.0" } as const ,
117
+ //@ts -expect-error This is a workaround
111
118
close : jest . fn ( ) . mockResolvedValue ( undefined ) ,
119
+ //@ts -expect-error This is a workaround
112
120
setAgentRunner : jest . fn ( ) . mockResolvedValue ( undefined ) ,
113
121
} as unknown as Session ;
114
122
0 commit comments