diff --git a/packages/vite/src/executors/test/vitest.impl.ts b/packages/vite/src/executors/test/vitest.impl.ts index af8f087b0896b..d83356a4b5ba7 100644 --- a/packages/vite/src/executors/test/vitest.impl.ts +++ b/packages/vite/src/executors/test/vitest.impl.ts @@ -8,8 +8,9 @@ import { import { CoverageOptions, File, Reporter } from 'vitest'; import { loadConfigFromFile } from 'vite'; import { VitestExecutorOptions } from './schema'; -import { relative } from 'path'; +import { relative, resolve } from 'path'; import { existsSync } from 'fs'; +import { registerTsConfigPaths } from '@nx/js/src/internal'; class NxReporter implements Reporter { deferred: { @@ -50,6 +51,10 @@ export async function* vitestExecutor( options: VitestExecutorOptions, context: ExecutorContext ) { + const projectRoot = + context.projectsConfigurations.projects[context.projectName].root; + registerTsConfigPaths(resolve(projectRoot, 'tsconfig.json')); + const { startVitest } = await (Function( 'return import("vitest/node")' )() as Promise);