Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular): use vitest generator instead of vite config generator #28696

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.serve.executor).toBe(
'@angular-devkit/build-angular:dev-server'
);
});
});

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