@@ -33,7 +33,7 @@ import {
3333 addProjectToTsSolutionWorkspace ,
3434 isUsingTsSolutionSetup ,
3535} from '@nx/js/src/utils/typescript/ts-solution-setup' ;
36- import type { VitestGeneratorSchema } from '@nx/vitest' ;
36+ import type { VitestGeneratorSchema } from '@nx/vitest/generators ' ;
3737import type { PackageJson } from 'nx/src/utils/package-json' ;
3838import { join } from 'path' ;
3939import type { Schema } from './schema' ;
@@ -238,17 +238,22 @@ async function addVitest(host: Tree, options: NormalizedSchema) {
238238 skipFormat : true ,
239239 addPlugin : options . addPlugin ,
240240 testEnvironment : 'node' ,
241+ coverageProvider : 'none' ,
241242 } satisfies Partial < VitestGeneratorSchema > ) ;
242243
243- addLocalRegistryScripts ( host ) ;
244+ const { startLocalRegistryPath, stopLocalRegistryPath } =
245+ addLocalRegistryScripts ( host ) ;
244246
245247 // Add globalSetup and globalTeardown to vitest config
246248 // Check for both .mts and .ts extensions (mts is checked first as it's the default created by @nx/vitest)
247249 const vitestConfigExtensions = [ 'mts' , 'ts' ] ;
248250 let vitestConfigPath : string | undefined ;
249251
250252 for ( const ext of vitestConfigExtensions ) {
251- const configPath = joinPathFragments ( options . projectRoot ) ;
253+ const configPath = joinPathFragments (
254+ options . projectRoot ,
255+ `vitest.config.${ ext } `
256+ ) ;
252257 if ( host . exists ( configPath ) ) {
253258 vitestConfigPath = configPath ;
254259 break ;
@@ -261,11 +266,15 @@ async function addVitest(host: Tree, options: NormalizedSchema) {
261266 offsetFromRoot ( options . projectRoot ) ,
262267 startLocalRegistryPath
263268 ) ;
264- const globalTeardownPath = join ( offsetFromRoot ( options . projectRoot ) ) ;
269+ const globalTeardownPath = join (
270+ offsetFromRoot ( options . projectRoot ) ,
271+ stopLocalRegistryPath
272+ ) ;
265273
266274 // Insert globalSetup and globalTeardown in the test config
267275 // Look for 'test: {' and insert our properties right after the opening brace
268276 const testConfigRegex = / ( t e s t : \s * \{ \s * ) / ;
277+ const match = testConfigRegex . exec ( vitestConfig ) ;
269278
270279 if ( match ) {
271280 // Extract the indentation from the next line to maintain consistent formatting
0 commit comments