File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ const waitForServer = async (
3838} ;
3939
4040/** Global setup function - starts viam-server before all tests */
41- export const setup = async ( ) : Promise < void > => {
41+ export const setup = async ( ) : Promise < ( ) => Promise < void > > => {
4242 console . log ( 'Starting viam-server for E2E tests...' ) ;
4343
4444 const binaryPath = path . resolve ( dirname , '../bin/viam-server' ) ;
@@ -88,6 +88,9 @@ export const setup = async (): Promise<void> => {
8888 process . env . VIAM_SERVER_URL = `http://${ VIAM_SERVER_HOST } :${ VIAM_SERVER_PORT } ` ;
8989
9090 console . log ( '✓ Global setup complete' ) ;
91+
92+ // Return teardown function for Vitest
93+ return teardown ;
9194} ;
9295
9396/** Global teardown function - stops viam-server after all tests */
@@ -96,7 +99,21 @@ export const teardown = async (): Promise<void> => {
9699
97100 if ( serverProcess ) {
98101 const exitPromise = new Promise < void > ( ( resolve ) => {
99- serverProcess ?. on ( 'exit' , ( ) => {
102+ if ( ! serverProcess ) {
103+ resolve ( ) ;
104+ return ;
105+ }
106+
107+ const timeout = setTimeout ( ( ) => {
108+ console . warn ( 'viam-server did not exit gracefully, forcing kill...' ) ;
109+ if ( serverProcess ) {
110+ serverProcess . kill ( 'SIGKILL' ) ;
111+ }
112+ resolve ( ) ;
113+ } , 5000 ) ;
114+
115+ serverProcess . on ( 'exit' , ( ) => {
116+ clearTimeout ( timeout ) ;
100117 serverProcess = undefined ;
101118 resolve ( ) ;
102119 } ) ;
Original file line number Diff line number Diff line change @@ -18,5 +18,6 @@ export default defineConfig({
1818 globalSetup : [ './e2e/helpers/global-setup.ts' ] ,
1919 setupFiles : [ './e2e/helpers/node-setup.ts' ] ,
2020 environment : 'node' ,
21+ teardownTimeout : 10_000 ,
2122 } ,
2223} ) ;
You can’t perform that action at this time.
0 commit comments