File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,10 @@ export class Vitest {
126
126
const serverRestart = server . restart
127
127
server . restart = async ( ...args ) => {
128
128
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 ( )
130
133
}
131
134
132
135
// since we set `server.hmr: false`, Vite does not auto restart itself
@@ -136,6 +139,9 @@ export class Vitest {
136
139
if ( isConfig ) {
137
140
await Promise . all ( this . _onRestartListeners . map ( fn => fn ( 'config' ) ) )
138
141
await serverRestart ( )
142
+ // watcher is recreated on restart
143
+ this . unregisterWatcher ( )
144
+ this . registerWatcher ( )
139
145
}
140
146
} )
141
147
}
@@ -729,8 +735,15 @@ export class Vitest {
729
735
}
730
736
731
737
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
+ }
733
745
return [ ]
746
+ }
734
747
735
748
const files : string [ ] = [ ]
736
749
You can’t perform that action at this time.
0 commit comments