vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Vitest plugin doesn't work with Angular v21 project

Open abhijit-chikane opened this issue 2 months ago • 3 comments

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

abhijit-chikane avatar Nov 22 '25 16:11 abhijit-chikane

Same here:

Image

I also tried adding a custom config via "ng generate config vitest", and add the config "global: true".

Image

Then The Error commes that Testbed.initTestEnvironment must be called:

Image

brabenetz avatar Nov 24 '25 19:11 brabenetz

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.

brabenetz avatar Nov 25 '25 07:11 brabenetz

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

sheremet-va avatar Nov 26 '25 08:11 sheremet-va