Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Coverage in library `unit-test` includes dependent library files and does not reduce runtime when using coverage.include

未关闭
#33,484 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
angular, typescript

调研方向

首先,使用两个相互依赖的 Angular workspace 库和 @angular/build:unit-test builder,通过 ng test lib-a --coverage 重现该问题。比较有无 coverage.include 时的 coverage 输出和执行时间;当依赖库文件被排除,并且限制 coverage 也能缩短运行时间时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

angular/build:unit-test area: @angular/build
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

When running unit tests for a library with @angular/build:unit-test, the coverage report includes files from other workspace libraries that the tested library depends on, which is unexpected.

Although this can be restricted with coverage.include, coverage execution time remains unchanged.

Minimal Reproduction
  1. Create two Angular libraries in the workspace (e.g. lib-a and lib-b)
  2. Make lib-a depend on lib-b
  3. Add a unit test in lib-a
  4. Run tests with coverage enabled:
ng test lib-a --coverage
Observed behavior
  • The coverage report contains files from lib-b, even though only lib-a is being tested.
  • Restricting coverage.include changes the generated report but does not noticeably reduce execution time.
Performance

Times below are for a single library test run inside a larger Angular monorepo where the tested library depends on ~7 other libraries from the same workspace.
Execution times vary depending on configuration (development vs production) used to build each of the libraries.

Without coverage:

Duration 24.94s
(transform 62.28s, setup 6.91s, import 98.85s, tests 982ms, environment 13.89s)

With coverage (production build):

Duration 154.60s
(transform 78.24s, setup 13.24s, import 135.76s, tests 1.58s, environment 19.90s)

With coverage (development build)

Duration 201.20s
(transform 57.83s, setup 10.09s, import 99.85s, tests 1.25s, environment 15.00s)
Your Environment
_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI       : 22.0.4
Angular           : 22.0.4
Node.js           : 24.16.0
Package Manager   : npm 11.13.0
Operating System  : linux x64

┌───────────────────────────────────┬───────────────────┬───────────────────┐
│ Package                           │ Installed Version │ Requested Version │
├───────────────────────────────────┼───────────────────┼───────────────────┤
│ @angular/animations               │ 22.0.4            │ ^22.0.4           │
│ @angular/build                    │ 22.0.4            │ ^22.0.4           │
│ @angular/cli                      │ 22.0.4            │ ^22.0.4           │
│ @angular/common                   │ 22.0.4            │ ^22.0.4           │
│ @angular/compiler                 │ 22.0.4            │ ^22.0.4           │
│ @angular/compiler-cli             │ 22.0.4            │ ^22.0.4           │
│ @angular/core                     │ 22.0.4            │ ^22.0.4           │
│ @angular/forms                    │ 22.0.4            │ ^22.0.4           │
│ @angular/localize                 │ 22.0.4            │ ^22.0.4           │
│ @angular/platform-browser         │ 22.0.4            │ ^22.0.4           │
│ @angular/platform-browser-dynamic │ 22.0.4            │ ^22.0.4           │
│ @angular/router                   │ 22.0.4            │ ^22.0.4           │
│ @angular/service-worker           │ 22.0.4            │ ^22.0.4           │
│ ng-packagr                        │ 22.0.0            │ ^22.0.0           │
│ rxjs                              │ 7.8.2             │ ~7.8.2            │
│ typescript                        │ 6.0.3             │ ^6.0.3            │
│ vitest                            │ 4.1.9             │ ^4.1.9            │
│ zone.js                           │ 0.16.2            │ ~0.16.2           │
└───────────────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?

No response

主要语言
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 摘要。