Skip to content

Conversation

@clydin
Copy link
Member

@clydin clydin commented Nov 4, 2025

This commit expands the config schematic to support generating a vitest-base.config.ts file and includes runner checks to prevent misconfiguration.

Changes include:

  • Added 'vitest' as a valid type for the config schematic in schema.json.
  • Created a new vitest-base.config.ts.template file for generating a basic Vitest configuration.
  • Implemented the addVitestConfig function in packages/schematics/angular/config/index.ts:
    • Verifies that the project's test target uses the @angular/build:unit-test builder.
    • Copies the vitest-base.config.ts template to the project root.
    • Sets the runnerConfig option to true in angular.json to enable automatic discovery.
    • Includes warning logic to notify users if the runner option in angular.json is explicitly set to karma, indicating that the generated Vitest config may not be used.

This commit expands the `config` schematic to support generating a `vitest-base.config.ts` file and includes runner checks to prevent misconfiguration.

Changes include:
- Added 'vitest' as a valid type for the `config` schematic in `schema.json`.
- Created a new `vitest-base.config.ts.template` file for generating a basic Vitest configuration.
- Implemented the `addVitestConfig` function in `packages/schematics/angular/config/index.ts`:
  - Verifies that the project's `test` target uses the `@angular/build:unit-test` builder.
  - Copies the `vitest-base.config.ts` template to the project root.
  - Sets the `runnerConfig` option to `true` in `angular.json` to enable automatic discovery.
  - Includes warning logic to notify users if the `runner` option in `angular.json` is explicitly set to `karma`, indicating that the generated Vitest config may not be used.
@clydin clydin added the target: rc This PR is targeted for the next release-candidate label Nov 4, 2025
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Nov 4, 2025
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 4, 2025
@alan-agius4 alan-agius4 merged commit 8edd3ef into angular:main Nov 4, 2025
35 checks passed
@alan-agius4
Copy link
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

@clydin clydin deleted the config/vitest-generate branch November 4, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @schematics/angular target: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants