angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

I'm having a problem with ng test and Angular v21

Open Sebastienpanda opened this issue 1 month ago • 5 comments

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

No

Description

Let me explain my problem. I'm trying to run tests using ng test, but I don't know why it suddenly closes the terminal and I don't get any errors. If I run pnpm run test or pnpm test using pnpm run test, I get these errors:

ELIFECYCLE Test failed. See above for more details.

I've searched on Google but haven't found anything about this issue.

I'm using a Windows environment.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

When I launch ng test, my terminal immediately shuts down. But if I run it via `pnpm run test`, I get this error ELIFECYCLE Test failed. See above for more details.

Please provide the environment you discovered this bug in (run ng version)

Angular CLI       : 21.0.1
Angular           : 21.0.1
Node.js           : 24.11.1
Package Manager   : pnpm 10.24.0
Operating System  : win32 x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.0.1            │ ^21.0.1           │
│ @angular/cli              │ 21.0.1            │ ^21.0.1           │
│ @angular/common           │ 21.0.1            │ ^21.0.0           │
│ @angular/compiler         │ 21.0.1            │ ^21.0.0           │
│ @angular/compiler-cli     │ 21.0.1            │ ^21.0.0           │
│ @angular/core             │ 21.0.1            │ ^21.0.0           │
│ @angular/forms            │ 21.0.1            │ ^21.0.0           │
│ @angular/platform-browser │ 21.0.1            │ ^21.0.0           │
│ @angular/router           │ 21.0.1            │ ^21.0.0           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 5.9.3             │ ~5.9.2            │
│ vitest                    │ 4.0.14            │ ^4.0.8            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else?

Image Image

Sebastienpanda avatar Nov 29 '25 12:11 Sebastienpanda

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

alan-agius4 avatar Dec 01 '25 09:12 alan-agius4

Hello @alan-agius4

here's the repo link. I'm using pnpm and I just ran this command without changing anything; it's the project as it was originally.

ng new blog --package-manager=pnpm

https://github.com/Sebastienpanda/repro-app

Sebastienpanda avatar Dec 01 '25 10:12 Sebastienpanda

I am able to run the reproduction without any issue.

alan-agius4 avatar Dec 02 '25 09:12 alan-agius4

On window?

Sebastienpanda avatar Dec 02 '25 09:12 Sebastienpanda

@Sebastienpanda, yes

alan-agius4 avatar Dec 04 '25 08:12 alan-agius4

I am observing the same behavior while running "ng test" with NPM in my projects. Weirdly, it sometimes successfully starts the Vitest watcher part of the "ng test". But only after re-running the script multiple times. Feels like a racing condition? I am using Angular version 21.0.1 and Vitest version 4.0.14 and Windows 11.

Everything works completely fine, if I set "watch": false in the angular.json's test configuration.

anedomansky avatar Dec 05 '25 08:12 anedomansky