- Notifications
You must be signed in to change notification settings - Fork12k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
f9cea6f
toaf08a63
CompareThere 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.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
When using the application build system via the `@angular/build` package(default for new projects starting in v20), a new experimental unit-testbuilder is available that initially uses vitest. This experimental systemis intended to provide support for investigation of future unit testingefforts within the Angular CLI. As this is experimental, no SemVer guaranteesare provided, the API and behavior may change, and there may be unexpectedbehavior. 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 alreadydefined for development. If differing option values are required for testing,an additional build target configuration specifically for testing can beused.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 supportedAn example configuration that would replace the `test` target for a projectis as follows:```"test": { "builder": "@angular/build:unit-test", "options": { "tsConfig": "tsconfig.spec.json", "buildTarget": "::development", "runner": "vitest" }}```
af08a63
to0e3a21c
Compare12def3a
intoangular:mainUh oh!
There was an error while loading.Please reload this page.
This issue has been automatically locked due to inactivity. Read more about ourautomatic conversation locking policy. This action has been performed automatically by a bot. |
Uh oh!
There was an error while loading.Please reload this page.
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:Example of modified new app spec file