Vitest plugin doesn't work with Angular v21 project
Describe the bug
Vitest plugin doesn't work with Angular v21 project
Reproduction
Created a new angular V21 project which has vitest support Installed the Vitest plugin trying to run the unit tests but it's not working
Output
It shows "The test run did not record any output." msg in Test Results tab
Extension Version
1.32.1
Vitest Version
^4.0.8
Validations
- [x] Check that you are using the latest version of the extension
- [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [x] The provided reproduction is a minimal reproducible example of the bug.
Same here:
I also tried adding a custom config via "ng generate config vitest", and add the config "global: true".
Then The Error commes that Testbed.initTestEnvironment must be called:
I believe the only viable workaround at the moment is to completely bypass the Angular CLI runner by setting up a custom Vitest runner configuration (e.g., via a dedicated vitest.config.ts file).
If full integration with Angular's internal runner turns out to be too complex to implement, it might be helpful to at least add documentation specifically for Angular 21+ projects. This could outline the necessary steps to replace ng test with vitest run (or npx vitest), including any required setup files, merges with vite.config.ts, and handling of component resource resolution for standalone components.
The official Angular integration is done in a way that vscode extension cannot support, and the Vitest team does not plan to maintain a custom handling for it. One way to negate this is to use Analog when running in Vitest: https://analogjs.org/docs/features/testing/vitest