-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Use vitest for unit tests. The main point here is not to improve the unit testing experience but gather experience with vitest and how to install it into an angular application. Also add one unitttest that does something such as calculating a USB Buffer for certain slider values.
Angular 20 added vitest as experimental backend for unit tests: https://blog.angular.dev/announcing-angular-v20-b5c9c06cf301
As of Angular 20.0, this does not yet work with zoneless applications. Revisit once zoneless applications are supported.
How to test:
- Create a vanilla angular project.
npm i vitest jsdom --save-dev
- Adjust
angular.json
and replace the section about tests:
"test": {
"builder": "@angular/build:unit-test",
"options": {
"tsConfig": "tsconfig.spec.json",
"buildTarget": "::development",
"runner": "vitest"
}
}
Try running the tests, they should work. Change the application to zoneless change detection and remove the zone.js polyfill from angular.json
. Run the tests again. Currently, they are failing as zone.js seems to be required.