Skip to content

Vitest config merging improvements#32810

Merged
clydin merged 3 commits intoangular:mainfrom
clydin:vitest/config-improvements
Mar 23, 2026
Merged

Vitest config merging improvements#32810
clydin merged 3 commits intoangular:mainfrom
clydin:vitest/config-improvements

Conversation

@clydin
Copy link
Member

@clydin clydin commented Mar 20, 2026

This PR introduces several architectural improvements to how the Angular CLI (@angular/build) merges and processes custom vitest.config.ts options.

Previously, certain CLI arguments would either silently clobber user-defined configuration arrays, or allow Vite's mergeConfig to create duplicated outputs. Additionally, we identified areas where vitest.config.ts properties could cause hidden performance overheads.

… configuration

When a user specifies `test.exclude` inside their `vitest.config.ts`, the tests are correctly excluded during Vitest's execution phase. However, because the Angular CLI extracts test files earlier in the process using its own `exclude` builder option, those skipped tests are still unnecessarily compiled by esbuild in-memory.

This adds a warning to explicitly notify developers of this hidden build overhead and suggests using the Angular CLI `exclude` option instead to improve performance.
@clydin clydin marked this pull request as ready for review March 20, 2026 17:30
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Mar 20, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several valuable improvements to how Vitest configurations are merged, addressing potential conflicts between CLI options and user-defined configurations. The changes to prioritize CLI arguments for reporters and to warn about performance implications of test.exclude are well-implemented. The new logic for merging coverage.exclude arrays is also a good step towards more intuitive behavior. However, I've identified a potential issue in the implementation of the coverage.exclude merging that could lead to incorrect behavior under certain conditions. The new tests are comprehensive and validate the intended changes effectively.

@clydin clydin force-pushed the vitest/config-improvements branch from 27dfcf6 to bbf5621 Compare March 20, 2026 17:41
clydin added 2 commits March 20, 2026 13:47
Previously, providing a --coverage-exclude CLI option to the builder would completely clobber any custom coverage.exclude items defined natively within vitest.config.ts.

This correctly merges both sources using an internal Set to prevent duplicate exclusions and preserves configurations so developers can combine global ignores alongside CLI-specific boundaries.
…ding Vitest configuration

When leveraging the Angular CLI to run tests with a specific set of `--reporters`, Vitest's underlying `mergeConfig` logic would normally array-concatenate the CLI reporters with any reporters defined natively inside `vitest.config.ts`. This led to duplicate output processors (e.g. running 'default' twice).

By explicitly wiping the original configurations when CLI overrides are present, the CLI now acts as a strict Source-of-Truth array replacer, which is the expected behavior for CI and custom targets.
@clydin clydin force-pushed the vitest/config-improvements branch from bbf5621 to 58bcba8 Compare March 20, 2026 17:47
@clydin clydin requested a review from alan-agius4 March 20, 2026 18:08
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 23, 2026
@clydin clydin merged commit 355ebe8 into angular:main Mar 23, 2026
37 checks passed
@clydin
Copy link
Member Author

clydin commented Mar 23, 2026

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

@clydin clydin deleted the vitest/config-improvements branch March 23, 2026 11:30
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: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants