···11import { defineConfig } from 'vitest/config'
22+import { cwdPlugin } from './cwdPlugin.js'
2334if (process.env.TEST_WATCH) {
45 // Patch stdin on the process so that we can fake it to seem like a real interactive terminal and pass the TTY checks
···89910export default defineConfig({
1011 envPrefix: ['VITE_', 'CUSTOM_', 'ROOT_'],
1212+ plugins: [cwdPlugin('ROOT')],
1113 test: {
1214 coverage: {
1315 enabled: true,
···315315316316 const cwd = process.cwd()
317317318318- const projects: (() => Promise<WorkspaceProject>)[] = []
318318+ const projects: WorkspaceProject[] = []
319319320320 try {
321321 // we have to resolve them one by one because CWD should depend on the project
322322 for (const filepath of filteredWorkspaces) {
323323 if (this.server.config.configFile === filepath) {
324324 const project = await this.createCoreProject()
325325- projects.push(() => Promise.resolve(project))
325325+ projects.push(project)
326326 continue
327327 }
328328 const dir = filepath.endsWith('/') ? filepath.slice(0, -1) : dirname(filepath)
329329 if (isMainThread)
330330 process.chdir(dir)
331331- // this just resolves the config, later we also wait when the server is resolved,
332332- // but we can do that in parallel because it doesn't depend on process.cwd()
333333- // this is strictly a performance optimization so we don't need to wait for server to start
334334- projects.push(await initializeProject(filepath, this, { workspaceConfigPath, test: cliOverrides }))
331331+ projects.push(
332332+ await initializeProject(filepath, this, { workspaceConfigPath, test: cliOverrides }),
333333+ )
335334 }
336335 }
337336 finally {
···339338 process.chdir(cwd)
340339 }
341340342342- const projectPromises: Promise<() => Promise<WorkspaceProject>>[] = []
341341+ const projectPromises: Promise<WorkspaceProject>[] = []
343342344343 projectsOptions.forEach((options, index) => {
345344 // we can resolve these in parallel because process.cwd() is not changed
···349348 if (!projects.length && !projectPromises.length)
350349 return [await this.createCoreProject()]
351350352352- const resolvedProjectsReceivers = [
351351+ const resolvedProjects = await Promise.all([
353352 ...projects,
354353 ...await Promise.all(projectPromises),
355355- ]
356356- // we need to wait when the server is resolved, we can do that in parallel
357357- const resolvedProjects = await Promise.all(
358358- resolvedProjectsReceivers.map(receiver => receiver()),
359359- )
354354+ ])
360355 const names = new Set<string>()
361356362357 for (const project of resolvedProjects) {