angular / angular/angular-cli

@angular/build:karma ignores overrides in karma.conf.js

未关闭
#30,956 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area: @angular/build devkit/build-angular:karma freq1: low severity3: broken type: bug/fix
主要语言
TypeScript
星标
27k
派生
11.8k
平均合并
14 小时 23 分钟
30 天内合并 PR
162

描述

### 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

Using the new `@angular/build:karma` builder, coverage overrides defined in the `karma.conf.js` are ignored.

### Minimal Reproduction

* clone https://github.com/fynnfeldpausch/karma-coverage
* take a look at `app.ts` - there is an additional method
* take a look at `karma.conf.js` and the defined coverage
* global coverage is set to 80%
* local coverage is set to 0% for `app.ts`
* run `ng test -- --no-watch --no-progress --browsers=ChromeHeadless --code-coverage`

### Exception or Error

```text
Test run fails with coverage errors:

19 08 2025 15:57:46.079:ERROR [coverage]: Chrome Headless 139.0.0.0 (Mac OS 10.15.7): Coverage for statements (75%) does not meet per-file (/repro-app/src/app/app.ts) threshold (80%)
19 08 2025 15:57:46.079:ERROR [coverage]: Chrome Headless 139.0.0.0 (Mac OS 10.15.7): Coverage for lines (66.66%) does not meet per-file (/repro-app/src/app/app.ts) threshold (80%)
19 08 2025 15:57:46.079:ERROR [coverage]: Chrome Headless 139.0.0.0 (Mac OS 10.15.7): Coverage for functions (0%) does not meet per-file (/repro-app/src/app/app.ts) threshold (80%)
```

### Your Environment

```text
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/

Angular CLI: 20.1.6
Node: 24.2.0
Package Manager: npm 11.3.0
OS: darwin arm64

Angular: 20.1.7
... common, compiler, compiler-cli, core, forms
... platform-browser, router

Package Version
------------------------------------------------------
@angular-devkit/architect 0.2001.6
@angular-devkit/core 20.1.6
@angular-devkit/schematics 20.1.6
@angular/build 20.1.6
@angular/cli 20.1.6
@schematics/angular 20.1.6
rxjs 7.8.2
typescript 5.8.3
zone.js 0.15.1
```

### Anything else relevant?

_No response_

贡献指南

打开贡献指南

调研方向

克隆链接的 karma-coverage 复现项目并检查 app.ts 和 karma.conf.js,然后运行列出的 ng test 命令以复现 coverage 失败。跟踪 @angular/build:karma 如何处理配置,并验证按文件设置的 coverage 覆盖项会被遵循,同时全局阈值仍然有效。

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

评估

技术栈
angular, typescript
领域
build-system, testing
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。