@@ -95,6 +95,7 @@ export class Vitest {
95
95
this . pool = undefined
96
96
this . coverageProvider = undefined
97
97
this . runningPromise = undefined
98
+ this . distPath = undefined !
98
99
this . projectsTestFiles . clear ( )
99
100
100
101
const resolved = resolveConfig ( this . mode , options , server . config , this . logger )
@@ -110,11 +111,6 @@ export class Vitest {
110
111
111
112
this . vitenode = new ViteNodeServer ( server , this . config . server )
112
113
113
- // if Vitest is running globally, then we should still import local vitest if possible
114
- const projectVitestPath = await this . vitenode . resolveId ( 'vitest' )
115
- const vitestDir = projectVitestPath ? resolve ( projectVitestPath . id , '../..' ) : rootDir
116
- this . distPath = join ( vitestDir , 'dist' )
117
-
118
114
const node = this . vitenode
119
115
this . runner = new ViteNodeRunner ( {
120
116
root : server . config . root ,
@@ -508,7 +504,19 @@ export class Vitest {
508
504
await project . initializeGlobalSetup ( )
509
505
}
510
506
507
+ private async initializeDistPath ( ) {
508
+ if ( this . distPath )
509
+ return
510
+
511
+ // if Vitest is running globally, then we should still import local vitest if possible
512
+ const projectVitestPath = await this . vitenode . resolveId ( 'vitest' )
513
+ const vitestDir = projectVitestPath ? resolve ( projectVitestPath . id , '../..' ) : rootDir
514
+ this . distPath = join ( vitestDir , 'dist' )
515
+ }
516
+
511
517
async runFiles ( paths : WorkspaceSpec [ ] , allTestsRun : boolean ) {
518
+ await this . initializeDistPath ( )
519
+
512
520
const filepaths = paths . map ( ( [ , file ] ) => file )
513
521
this . state . collectPaths ( filepaths )
514
522
0 commit comments