File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,10 @@ export class Vitest {
126126 const serverRestart = server . restart
127127 server . restart = async ( ...args ) => {
128128 await Promise . all ( this . _onRestartListeners . map ( fn => fn ( ) ) )
129- return await serverRestart ( ...args )
129+ await serverRestart ( ...args )
130+ // watcher is recreated on restart
131+ this . unregisterWatcher ( )
132+ this . registerWatcher ( )
130133 }
131134
132135 // since we set `server.hmr: false`, Vite does not auto restart itself
@@ -136,6 +139,9 @@ export class Vitest {
136139 if ( isConfig ) {
137140 await Promise . all ( this . _onRestartListeners . map ( fn => fn ( 'config' ) ) )
138141 await serverRestart ( )
142+ // watcher is recreated on restart
143+ this . unregisterWatcher ( )
144+ this . registerWatcher ( )
139145 }
140146 } )
141147 }
@@ -729,8 +735,15 @@ export class Vitest {
729735 }
730736
731737 const projects = this . getModuleProjects ( id )
732- if ( ! projects . length )
738+ if ( ! projects . length ) {
739+ // if there are no modules it's possible that server was restarted
740+ // we don't have information about importers anymore, so let's check if the file is a test file at least
741+ if ( this . state . filesMap . has ( id ) || this . projects . some ( project => project . isTestFile ( id ) ) ) {
742+ this . changedTests . add ( id )
743+ return [ id ]
744+ }
733745 return [ ]
746+ }
734747
735748 const files : string [ ] = [ ]
736749
You can’t perform that action at this time.
0 commit comments