88
99import type { BuilderOutput } from '@angular-devkit/architect' ;
1010import assert from 'node:assert' ;
11- import path from 'node:path' ;
11+ import path , { join } from 'node:path' ;
1212import type { Vitest } from 'vitest/node' ;
1313import {
1414 DevServerExternalResultMetadata ,
@@ -150,6 +150,10 @@ export class VitestExecutor implements TestExecutor {
150150 watch,
151151 browserViewport,
152152 ui,
153+ projectRoot,
154+ runnerConfig,
155+ projectSourceRoot,
156+ cacheOptions,
153157 } = this . options ;
154158 const projectName = this . projectName ;
155159
@@ -171,7 +175,7 @@ export class VitestExecutor implements TestExecutor {
171175 const browserOptions = await setupBrowserConfiguration (
172176 browsers ,
173177 debug ,
174- this . options . projectSourceRoot ,
178+ projectSourceRoot ,
175179 browserViewport ,
176180 ) ;
177181 if ( browserOptions . errors ?. length ) {
@@ -186,7 +190,7 @@ export class VitestExecutor implements TestExecutor {
186190 const testSetupFiles = this . prepareSetupFiles ( ) ;
187191 const projectPlugins = createVitestPlugins ( {
188192 workspaceRoot,
189- projectSourceRoot : this . options . projectSourceRoot ,
193+ projectSourceRoot,
190194 projectName,
191195 buildResultFiles : this . buildResultFiles ,
192196 testFileToEntryPoint : this . testFileToEntryPoint ,
@@ -200,10 +204,9 @@ export class VitestExecutor implements TestExecutor {
200204 }
201205 : { } ;
202206
203- const runnerConfig = this . options . runnerConfig ;
204207 const externalConfigPath =
205208 runnerConfig === true
206- ? await findVitestBaseConfig ( [ this . options . projectRoot , this . options . workspaceRoot ] )
209+ ? await findVitestBaseConfig ( [ projectRoot , workspaceRoot ] )
207210 : runnerConfig ;
208211
209212 return startVitest (
@@ -214,12 +217,15 @@ export class VitestExecutor implements TestExecutor {
214217 root : workspaceRoot ,
215218 project : projectName ,
216219 outputFile,
220+ cache : cacheOptions . enabled ? undefined : false ,
217221 testNamePattern : this . options . filter ,
218222 watch,
219223 ui,
220224 ...debugOptions ,
221225 } ,
222226 {
227+ // Note `.vitest` is auto appended to the path.
228+ cacheDir : cacheOptions . path ,
223229 server : {
224230 // Disable the actual file watcher. The boolean watch option above should still
225231 // be enabled as it controls other internal behavior related to rerunning tests.
@@ -230,7 +236,7 @@ export class VitestExecutor implements TestExecutor {
230236 browser : browserOptions . browser ,
231237 coverage,
232238 projectName,
233- projectSourceRoot : this . options . projectSourceRoot ,
239+ projectSourceRoot,
234240 optimizeDepsInclude : this . externalMetadata . implicitBrowser ,
235241 reporters,
236242 setupFiles : testSetupFiles ,
0 commit comments