···126126 const serverRestart = server.restart
127127 server.restart = async (...args) => {
128128 await Promise.all(this._onRestartListeners.map(fn => fn()))
129129- return await serverRestart(...args)
129129+ await serverRestart(...args)
130130+ // watcher is recreated on restart
131131+ this.unregisterWatcher()
132132+ this.registerWatcher()
130133 }
131134132135 // since we set `server.hmr: false`, Vite does not auto restart itself
···136139 if (isConfig) {
137140 await Promise.all(this._onRestartListeners.map(fn => fn('config')))
138141 await serverRestart()
142142+ // watcher is recreated on restart
143143+ this.unregisterWatcher()
144144+ this.registerWatcher()
139145 }
140146 })
141147 }
···729735 }
730736731737 const projects = this.getModuleProjects(id)
732732- if (!projects.length)
738738+ if (!projects.length) {
739739+ // if there are no modules it's possible that server was restarted
740740+ // we don't have information about importers anymore, so let's check if the file is a test file at least
741741+ if (this.state.filesMap.has(id) || this.projects.some(project => project.isTestFile(id))) {
742742+ this.changedTests.add(id)
743743+ return [id]
744744+ }
733745 return []
746746+ }
734747735748 const files: string[] = []
736749