77 */
88
99import path from 'node:path' ;
10- import type { VitestPluginContext } from 'vitest/node' ;
1110import { BuildOutputFileType } from '../../../../tools/esbuild/bundler-files' ;
1211import { toPosixPath } from '../../../../utils/path' ;
1312import type { ResultFile } from '../../../application/results' ;
1413import { createVitestPlugins } from './plugins' ;
1514
1615describe ( 'createVitestPlugins' , ( ) => {
17- it ( 'resolves and loads setup files when vitestConfig.root differs from workspaceRoot (e.g., symlink or subst drive) ' , async ( ) => {
16+ it ( 'resolves and loads setup and spec files when vitestConfig.root differs from workspaceRoot' , async ( ) => {
1817 const workspaceRoot = path . resolve ( '/logical-workspace/test-project' ) ;
1918 const physicalRoot = toPosixPath ( path . resolve ( '/physical-disk/tmp/test-project' ) ) ;
2019 const specFile = toPosixPath ( path . join ( workspaceRoot , 'src/app/app.spec.ts' ) ) ;
@@ -57,14 +56,14 @@ describe('createVitestPlugins', () => {
5756 expect ( inMemoryPlugin ) . toBeDefined ( ) ;
5857
5958 const configureVitest = inMemoryPlugin ?. configureVitest as
60- ( ( context : VitestPluginContext ) => void ) | undefined ;
59+ ( ( context : { vitest : { config : { root : string } } } ) => void ) | undefined ;
6160 configureVitest ?.( {
6261 vitest : {
6362 config : {
6463 root : physicalRoot ,
6564 } ,
6665 } ,
67- } as unknown as VitestPluginContext ) ;
66+ } ) ;
6867
6968 const resolveId = inMemoryPlugin ?. resolveId as (
7069 id : string ,
@@ -80,5 +79,11 @@ describe('createVitestPlugins', () => {
8079
8180 const loadedSetup = await load ( expectedSetupId ) ;
8281 expect ( loadedSetup ?. code ) . toBe ( 'console.log("init-compiler");' ) ;
82+
83+ const resolvedSpecId = resolveId ( `${ physicalRoot } /src/app/app.spec.ts` , undefined ) ;
84+ expect ( resolvedSpecId ) . toBe ( specFile ) ;
85+
86+ const loadedSpec = await load ( specFile ) ;
87+ expect ( loadedSpec ?. code ) . toBe ( 'console.log("spec");' ) ;
8388 } ) ;
8489} ) ;
0 commit comments