angular / angular/angular-cli

`unit-test` builder with `vitest` is slow for testing and for code coverage

Ouverte
#31,724 17 commentaires 2 réactions 0 personnes assignées Voir sur GitHub
angular/build:unit-test area: @angular/build freq1: low needs: investigation severity4: memory/performance
Langage dominant
TypeScript
Étoiles
27k
Forks
11.8k
Merge moyen
14 h 23 min
PR mergées (30 j)
162

Description

### Command

test

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

I migrated a very small existing project using the jasmine-to-vitest schematic and code coverage is fairly slow when using vitest (roughly 80 tests).

With the `karma` builder:

```
ng test --no-watch 9,99s user 1,71s system 214% cpu 5,459 total
ng test --no-watch --code-coverage 17,82s user 2,42s system 232% cpu 8,719 total
```

When migrates to the unit-test builder (and a few tests disabled):

```
ng test --no-watch 18,49s user 3,33s system 259% cpu 8,396 total
ng test --no-watch --coverage 38,46s user 4,66s system 210% cpu 20,535 total
```

The tests themselves takes 18s (10s with Karma), and the code coverage takes 20s instead of 8s. This is very noticeable when using vitest.

### Minimal Reproduction

This is probably reproducible in a new CLI project, by generating a bunch of components and comparing test times.

### Exception or Error

```text

```

### Your Environment

```text
Angular CLI : 21.0.0-rc.1
Angular : 21.0.0-rc.1
Node.js : 22.18.0
Package Manager : npm 10.9.0
Operating System : darwin arm64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 21.0.0-rc.1 │ 21.0.0-rc.1 │
│ @angular/cli │ 21.0.0-rc.1 │ 21.0.0-rc.1 │
│ @angular/common │ 21.0.0-rc.1 │ 21.0.0-rc.1 │
│ @angular/compiler │ 21.0.0-rc.1 │ 21.0.0-rc.1 │
│ @angular/compiler-cli │ 21.0.0-rc.1 │ 21.0.0-rc.1 │
│ @angular/core │ 21.0.0-rc.1 │ 21.0.0-rc.1 │
│ @angular/forms │ 21.0.0-rc.1 │ 21.0.0-rc.1 │
│ @angular/localize │ 21.0.0-rc.1 │ 21.0.0-rc.1 │
│ @angular/platform-browser │ 21.0.0-rc.1 │ 21.0.0-rc.1 │
│ @angular/router │ 21.0.0-rc.1 │ 21.0.0-rc.1 │
│ rxjs │ 7.8.2 │ 7.8.2 │
│ typescript │ 5.9.3 │ 5.9.3 │
│ vitest │ 4.0.8 │ 4.0.8 │
```

### Anything else relevant?

Of course this is maybe an upstream problem, but I thought it was worth mentioning it.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par reproduire les temps signalés avec les commandes `ng test --no-watch` et de couverture dans un petit projet Angular CLI utilisant le builder `unit-test` et Vitest, puis comparez-les avec Karma. Lisez les points d’entrée du builder unit-test et du schematic jasmine-to-vitest concernés par la migration. Le travail est terminé lorsque la source du ralentissement est identifiée et que l’amélioration des temps d’exécution des tests et de la couverture est démontrée.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
performance, testing, tooling
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Active
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.