@@ -53,7 +53,7 @@ export class Vitest {
53
53
restartsCount = 0
54
54
runner : ViteNodeRunner = undefined !
55
55
56
- private coreWorkspace ! : WorkspaceProject
56
+ private coreWorkspaceProject ! : WorkspaceProject
57
57
58
58
public projects : WorkspaceProject [ ] = [ ]
59
59
private projectsTestFiles = new Map < string , Set < WorkspaceProject > > ( )
@@ -145,12 +145,12 @@ export class Vitest {
145
145
runner : this . runner ,
146
146
server : this . vitenode ,
147
147
} )
148
- this . coreWorkspace = coreWorkspace
148
+ this . coreWorkspaceProject = coreWorkspace
149
149
return coreWorkspace
150
150
}
151
151
152
152
public getCoreWorkspaceProject ( ) : WorkspaceProject | null {
153
- return this . coreWorkspace || null
153
+ return this . coreWorkspaceProject || null
154
154
}
155
155
156
156
public getProjectByTaskId ( taskId : string ) : WorkspaceProject {
@@ -198,7 +198,7 @@ export class Vitest {
198
198
onlyFiles : false ,
199
199
markDirectories : true ,
200
200
cwd : this . config . root ,
201
- ignore : [ '**/node_modules/**' ] ,
201
+ ignore : [ '**/node_modules/**' , '**/*.timestamp-*' ] ,
202
202
}
203
203
204
204
const workspacesFs = await fg ( workspaceGlobMatches , globOptions )
@@ -221,6 +221,21 @@ export class Vitest {
221
221
return filepath
222
222
} ) )
223
223
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
+
224
239
const overridesOptions = [
225
240
'logHeapUsage' ,
226
241
'allowOnly' ,
@@ -239,7 +254,7 @@ export class Vitest {
239
254
return acc
240
255
} , { } as UserConfig )
241
256
242
- const projects = resolvedWorkspacesPaths . map ( async ( workspacePath ) => {
257
+ const projects = filteredWorkspaces . map ( async ( workspacePath ) => {
243
258
// don't start a new server, but reuse existing one
244
259
if (
245
260
this . server . config . configFile === workspacePath
@@ -725,7 +740,8 @@ export class Vitest {
725
740
if ( ! this . closingPromise ) {
726
741
const closePromises = this . projects . map ( w => w . close ( ) . then ( ( ) => w . server = undefined as any ) )
727
742
// 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 ) )
729
745
closePromises . push ( this . server . close ( ) . then ( ( ) => this . server = undefined as any ) )
730
746
731
747
if ( this . pool )
0 commit comments