Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

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

未關閉
#31,724 17 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
angular, typescript

研究方向

首先,在一個使用 unit-test builder 和 Vitest 的小型 Angular CLI 專案中,使用 ng test --no-watch 和 coverage 指令重現回報的耗時,然後將其與 Karma 進行比較。閱讀遷移所涉及的 unit-test builder 和 jasmine-to-vitest schematic 入口點。找出變慢的來源,並證明測試和 coverage 耗時有所改善後,即表示完成。

由索引模型根據 Issue 內容生成。

描述

angular/build:unit-test area: @angular/build freq1: low needs: investigation severity4: memory/performance
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

Your Environment
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.

主要語言
TypeScript
星號
27k
分支
11.8k
平均合併
17 小時 25 分鐘
30 天內合併 PR
183

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

angular/angular-cli 的其他 Issue

查看 angular/angular-cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。