@@ -26,6 +26,7 @@ describe('runServer', () => {
2626 let mockHttpHandle : HttpServerHandle ;
2727 let mockClose : jest . Mock ;
2828 let processOnSpy : jest . SpyInstance ;
29+ let processOffSpy : jest . SpyInstance ;
2930
3031 beforeEach ( ( ) => {
3132 jest . clearAllMocks ( ) ;
@@ -51,15 +52,17 @@ describe('runServer', () => {
5152
5253 MockStartHttpTransport . mockResolvedValue ( mockHttpHandle ) ;
5354
54- // Spy on process.on method
55+ // Spy on process methods
5556 processOnSpy = jest . spyOn ( process , 'on' ) . mockImplementation ( ) ;
57+ processOffSpy = jest . spyOn ( process , 'off' ) ;
5658
5759 // Mock process.exit to prevent Jest from exiting
5860 jest . spyOn ( process , 'exit' ) . mockImplementation ( ( ( ) => { } ) as never ) ;
5961 } ) ;
6062
6163 afterEach ( ( ) => {
6264 processOnSpy . mockRestore ( ) ;
65+ processOffSpy . mockRestore ( ) ;
6366 // Note: We don't call jest.restoreAllMocks() here as it would clear module mocks
6467 // The memoization cache persists across tests, which is expected behavior
6568 } ) ;
@@ -175,6 +178,7 @@ describe('runServer', () => {
175178
176179 await serverInstance . stop ( ) ;
177180
181+ expect ( processOffSpy ) . toHaveBeenCalledWith ( 'SIGINT' , expect . any ( Function ) ) ;
178182 expect ( serverInstance . isRunning ( ) ) . toBe ( false ) ;
179183 expect ( {
180184 events : MockLog . info . mock . calls
0 commit comments