-
Notifications
You must be signed in to change notification settings - Fork 12k
feat(@angular/build): add experimental vitest unit-testing support #30130
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
Merged
+1,378
−4
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f9cea6f
to
af08a63
Compare
alan-agius4
requested changes
Apr 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, just some minor things.
When using the application build system via the `@angular/build` package (default for new projects starting in v20), a new experimental unit-test builder is available that initially uses vitest. This experimental system is intended to provide support for investigation of future unit testing efforts within the Angular CLI. As this is experimental, no SemVer guarantees are provided, the API and behavior may change, and there may be unexpected behavior. Available test runners may be added or removed as well. The setup is somewhat different than the previous unit-testing builders. It uses a similar mechanism to that of the `dev-server` and requires a `buildTarget` option. This allows the code building aspects of the unit- testing process to leverage pre-existing option values that are already defined for development. If differing option values are required for testing, an additional build target configuration specifically for testing can be used. The current vitest support has multiple caveats including but not limited to: * No watch support * `jsdom` based testing only (`jsdom` must be installed in the project) * Custom vitest configuration is not supported An example configuration that would replace the `test` target for a project is as follows: ``` "test": { "builder": "@angular/build:unit-test", "options": { "tsConfig": "tsconfig.spec.json", "buildTarget": "::development", "runner": "vitest" } } ```
af08a63
to
0e3a21c
Compare
alan-agius4
approved these changes
Apr 23, 2025
alan-agius4
approved these changes
Apr 23, 2025
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
detected: feature
PR contains a feature commit
target: major
This PR is targeted for the next major release
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using the application build system via the
@angular/build
package (default for new projects starting in v20), a new experimental unit-test builder is available that initially uses vitest. This experimental system is intended to provide support for investigation of future unit testing efforts within the Angular CLI. As this is experimental, no SemVer guarantees are provided, the API and behavior may change, and there may be unexpected behavior. Available test runners may be added or removed as well.The setup is somewhat different than the previous unit-testing builders. It uses a similar mechanism to that of the
dev-server
and requires abuildTarget
option. This allows the code building aspects of the unit-testing process to leverage pre-existing option values that are already defined for development. If differing option values are required for testing, an additional build target configuration specifically for testing can be used.The current vitest support has multiple caveats including but not limited to:
jsdom
based testing only (jsdom
must be installed in the project)An example configuration that would replace the
test
target for a project is as follows: