@@ -135,6 +135,7 @@ describe("App in production mode", async () => {
135135 "post /v1/upload" : uploadEndpoint ,
136136 } ;
137137 vi . spyOn ( process . stdout , "write" ) . mockImplementation ( vi . fn ( ) ) ; // mutes logo output
138+ const beforeExit = vi . fn ( ) ;
138139 const config = createConfig ( {
139140 http : { listen : port } ,
140141 compression : { threshold : 1 } ,
@@ -165,7 +166,7 @@ describe("App in production mode", async () => {
165166 } ,
166167 cors : false ,
167168 startupLogo : true ,
168- gracefulShutdown : { events : [ "FAKE" ] } ,
169+ gracefulShutdown : { events : [ "FAKE" ] , beforeExit } ,
169170 logger,
170171 childLoggerProvider : ( { parent } ) =>
171172 Object . defineProperty ( parent , "isChild" , { value : true } ) ,
@@ -592,7 +593,7 @@ describe("App in production mode", async () => {
592593
593594 describe ( "Shutdown" , ( ) => {
594595 test ( "should terminate suspended request gracefully on signal" , async ( ) => {
595- const spy = vi
596+ const exitSpy = vi
596597 . spyOn ( process , "exit" )
597598 . mockImplementation ( vi . fn < typeof process . exit > ( ) ) ;
598599 fetch ( `http://127.0.0.1:${ port } /v1/long` ) . catch ( ( err ) =>
@@ -606,7 +607,8 @@ describe("App in production mode", async () => {
606607 } ) ;
607608 await setTimeout ( 1500 ) ;
608609 expect ( server . listening ) . toBeFalsy ( ) ;
609- expect ( spy ) . toHaveBeenCalled ( ) ;
610+ expect ( beforeExit ) . toHaveBeenCalledOnce ( ) ;
611+ expect ( exitSpy ) . toHaveBeenCalled ( ) ;
610612 } ) ;
611613 } ) ;
612614} ) ;
0 commit comments