Feature Request: Support Vitest #5064
-
Describe the feature or problem you'd like to solveI know jest is supported, but is Vitest? The syntax is very similar. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 3 replies
-
|
Hey @NateRadebaugh, personally, I don't have experience with So if |
Beta Was this translation helpful? Give feedback.
-
|
it needs the equivalent of jest-preset-angular |
Beta Was this translation helpful? Give feedback.
-
|
Could you please consider adding Vitest support to ng-mocks? It's 2025, and Vitest has become increasingly popular due to its speed, native ESM support, and seamless integration with Vite. With Angular 18 adopting Vite as its default build system, many developers are transitioning to Vitest for testing. Tools like AnalogJS have made integrating Vitest into Angular projects straightforward. Adding support for Vitest in ng-mocks would greatly benefit the community. |
Beta Was this translation helpful? Give feedback.
-
|
I have only checked services and not rendering (we are using storybook for testing UI), and it works just fine. It is basically using the analogjs plugin for compiling angular. |
Beta Was this translation helpful? Give feedback.
-
|
I noted that angular 20 added experimental vitest browser support to unit-testing: see PR angular/angular-cli#30168 |
Beta Was this translation helpful? Give feedback.
-
|
Note, that if you are using MockComponent and you may encounter errors related to missing providers such as You can fix them by adjusting your |
Beta Was this translation helpful? Give feedback.
-
|
I tried running my test cases with Vitest, but I had previously run them successfully using Karma. Log was filled with weird error like. Vitest seems quite slow—it took around 27 minutes, whereas the same tests ran in about 6-7 minutes with Karma. |
Beta Was this translation helpful? Give feedback.
Hey @NateRadebaugh,
personally, I don't have experience with
Vitest, but if it's very similar it should work.The only thing
ng-mocksrequires isangular,beforeEach,afterEach,beforeAllandafterAll.So if
Vitestis providing them,ng-mocksshould be compatible with it.