@@ -53,7 +53,7 @@ export class Vitest {
5353 restartsCount = 0
5454 runner : ViteNodeRunner = undefined !
5555
56- private coreWorkspace ! : WorkspaceProject
56+ private coreWorkspaceProject ! : WorkspaceProject
5757
5858 public projects : WorkspaceProject [ ] = [ ]
5959 private projectsTestFiles = new Map < string , Set < WorkspaceProject > > ( )
@@ -145,12 +145,12 @@ export class Vitest {
145145 runner : this . runner ,
146146 server : this . vitenode ,
147147 } )
148- this . coreWorkspace = coreWorkspace
148+ this . coreWorkspaceProject = coreWorkspace
149149 return coreWorkspace
150150 }
151151
152152 public getCoreWorkspaceProject ( ) : WorkspaceProject | null {
153- return this . coreWorkspace || null
153+ return this . coreWorkspaceProject || null
154154 }
155155
156156 public getProjectByTaskId ( taskId : string ) : WorkspaceProject {
@@ -198,7 +198,7 @@ export class Vitest {
198198 onlyFiles : false ,
199199 markDirectories : true ,
200200 cwd : this . config . root ,
201- ignore : [ '**/node_modules/**' ] ,
201+ ignore : [ '**/node_modules/**' , '**/*.timestamp-*' ] ,
202202 }
203203
204204 const workspacesFs = await fg ( workspaceGlobMatches , globOptions )
@@ -221,6 +221,21 @@ export class Vitest {
221221 return filepath
222222 } ) )
223223
224+ const workspacesByFolder = resolvedWorkspacesPaths
225+ . reduce ( ( configByFolder , filepath ) => {
226+ const dir = dirname ( filepath )
227+ configByFolder [ dir ] ??= [ ]
228+ configByFolder [ dir ] . push ( filepath )
229+ return configByFolder
230+ } , { } as Record < string , string [ ] > )
231+
232+ const filteredWorkspaces = Object . values ( workspacesByFolder ) . map ( ( configFiles ) => {
233+ if ( configFiles . length === 1 )
234+ return configFiles [ 0 ]
235+ const vitestConfig = configFiles . find ( configFile => basename ( configFile ) . startsWith ( 'vitest.config' ) )
236+ return vitestConfig || configFiles [ 0 ]
237+ } )
238+
224239 const overridesOptions = [
225240 'logHeapUsage' ,
226241 'allowOnly' ,
@@ -239,7 +254,7 @@ export class Vitest {
239254 return acc
240255 } , { } as UserConfig )
241256
242- const projects = resolvedWorkspacesPaths . map ( async ( workspacePath ) => {
257+ const projects = filteredWorkspaces . map ( async ( workspacePath ) => {
243258 // don't start a new server, but reuse existing one
244259 if (
245260 this . server . config . configFile === workspacePath
@@ -725,7 +740,8 @@ export class Vitest {
725740 if ( ! this . closingPromise ) {
726741 const closePromises = this . projects . map ( w => w . close ( ) . then ( ( ) => w . server = undefined as any ) )
727742 // close the core workspace server only once
728- if ( this . coreWorkspace && ! this . projects . includes ( this . coreWorkspace ) )
743+ // it's possible that it's not initialized at all because it's not running any tests
744+ if ( ! this . coreWorkspaceProject || ! this . projects . includes ( this . coreWorkspaceProject ) )
729745 closePromises . push ( this . server . close ( ) . then ( ( ) => this . server = undefined as any ) )
730746
731747 if ( this . pool )
0 commit comments