diff --git a/packages/angular/src/generators/application/application.spec.ts b/packages/angular/src/generators/application/application.spec.ts index 023aea6f27da4..b4f8e90d2c96b 100644 --- a/packages/angular/src/generators/application/application.spec.ts +++ b/packages/angular/src/generators/application/application.spec.ts @@ -800,6 +800,26 @@ describe('app', () => { appTree.read('my-app/vite.config.mts', 'utf-8') ).toMatchSnapshot(); }); + + it('should not override build configuration when using vitest as a test runner', async () => { + await generateApp(appTree, 'my-app', { + unitTestRunner: UnitTestRunner.Vitest, + }); + const { targets } = readProjectConfiguration(appTree, 'my-app'); + expect(targets.build.executor).toBe( + '@angular-devkit/build-angular:application' + ); + }); + + it('should not override serve configuration when using vitest as a test runner', async () => { + await generateApp(appTree, 'my-app', { + unitTestRunner: UnitTestRunner.Vitest, + }); + const { targets } = readProjectConfiguration(appTree, 'my-app'); + expect(targets.serve.executor).toBe( + '@angular-devkit/build-angular:dev-server' + ); + }); }); describe('none', () => { diff --git a/packages/angular/src/generators/utils/add-vitest.ts b/packages/angular/src/generators/utils/add-vitest.ts index 79383c97647ab..e8a7777bf4003 100644 --- a/packages/angular/src/generators/utils/add-vitest.ts +++ b/packages/angular/src/generators/utils/add-vitest.ts @@ -30,7 +30,7 @@ export async function addVitest( ); } - const { createOrEditViteConfig, viteConfigurationGenerator } = ensurePackage< + const { createOrEditViteConfig, vitestGenerator } = ensurePackage< typeof import('@nx/vite') >('@nx/vite', nxVersion); @@ -58,12 +58,13 @@ getTestBed().initTestEnvironment( ` ); - await viteConfigurationGenerator(tree, { + await vitestGenerator(tree, { project: options.name, - newProject: true, uiFramework: 'none', - includeVitest: true, + skipViteConfig: true, testEnvironment: 'jsdom', + coverageProvider: 'v8', + addPlugin: false, }); createOrEditViteConfig(