diff --git a/packages/js/src/generators/library/library.spec.ts b/packages/js/src/generators/library/library.spec.ts index 5a80ea163db..4d36f82bf14 100644 --- a/packages/js/src/generators/library/library.spec.ts +++ b/packages/js/src/generators/library/library.spec.ts @@ -1773,7 +1773,7 @@ describe('lib', () => { }); describe('--testEnvironment', () => { - it('should generate a vite config with testEnvironment set to node', async () => { + it('should generate a vitest config with testEnvironment set to node', async () => { await libraryGenerator(tree, { ...defaultOptions, directory: 'my-node-lib', @@ -1781,12 +1781,13 @@ describe('lib', () => { testEnvironment: 'node', }); - const content = tree.read('my-node-lib/vite.config.ts', 'utf-8'); + expect(tree.exists('my-node-lib/vite.config.ts')).toBe(false); + const content = tree.read('my-node-lib/vitest.config.mts', 'utf-8'); expect(content).toContain(`environment: 'node'`); }); - it('should generate a vite config with testEnvironment set to jsdom by default', async () => { + it('should generate a vitest config with testEnvironment set to jsdom by default', async () => { await libraryGenerator(tree, { ...defaultOptions, directory: 'my-jsdom-lib', @@ -1794,7 +1795,8 @@ describe('lib', () => { testEnvironment: undefined, }); - const content = tree.read('my-jsdom-lib/vite.config.ts', 'utf-8'); + expect(tree.exists('my-jsdom-lib/vite.config.ts')).toBe(false); + const content = tree.read('my-jsdom-lib/vitest.config.mts', 'utf-8'); expect(content).toContain(`environment: 'jsdom'`); }); diff --git a/packages/js/src/generators/library/library.ts b/packages/js/src/generators/library/library.ts index 8a80bcf8be8..cd50733912e 100644 --- a/packages/js/src/generators/library/library.ts +++ b/packages/js/src/generators/library/library.ts @@ -173,7 +173,6 @@ export async function libraryGeneratorInternal( options.unitTestRunner === 'vitest' && options.bundler !== 'vite' // Test would have been set up already ) { - const { createOrEditViteConfig } = ensurePackage('@nx/vite', nxVersion); ensurePackage('@nx/vitest', nxVersion); // nx-ignore-next-line const { configurationGenerator } = require('@nx/vitest/generators'); @@ -188,16 +187,6 @@ export async function libraryGeneratorInternal( addPlugin: options.addPlugin, }); tasks.push(vitestTask); - createOrEditViteConfig( - tree, - { - project: options.name, - includeLib: false, - includeVitest: true, - testEnvironment: options.testEnvironment, - }, - true - ); } if (!schema.skipTsConfig && !options.isUsingTsSolutionConfig) { diff --git a/packages/plugin/src/generators/plugin/plugin.spec.ts b/packages/plugin/src/generators/plugin/plugin.spec.ts index 49081ef1f9a..541ecfea440 100644 --- a/packages/plugin/src/generators/plugin/plugin.spec.ts +++ b/packages/plugin/src/generators/plugin/plugin.spec.ts @@ -236,7 +236,7 @@ describe('NxPlugin Plugin Generator', () => { }); describe('vitest', () => { - it('should generate test files with vite.config.ts', async () => { + it('should generate test files with vitest.config.mts', async () => { await pluginGenerator( tree, getSchema({ @@ -245,7 +245,8 @@ describe('NxPlugin Plugin Generator', () => { }) ); - ['my-plugin/vite.config.ts'].forEach((path) => + expect(tree.exists('my-plugin/vite.config.ts')).toBeFalsy(); + ['my-plugin/vitest.config.mts'].forEach((path) => expect(tree.exists(path)).toBeTruthy() );