Skip to content

Commit

Permalink
fix(angular): use vitest generator instead of vite config generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Oct 30, 2024
1 parent dbbc3fc commit 5adf0e2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
20 changes: 20 additions & 0 deletions packages/angular/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.build.executor).toBe(
'@angular-devkit/build-angular:application'
);
});
});

describe('none', () => {
Expand Down
9 changes: 5 additions & 4 deletions packages/angular/src/generators/utils/add-vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function addVitest(
);
}

const { createOrEditViteConfig, viteConfigurationGenerator } = ensurePackage<
const { createOrEditViteConfig, vitestGenerator } = ensurePackage<
typeof import('@nx/vite')
>('@nx/vite', nxVersion);

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 5adf0e2

Please sign in to comment.