angular / angular/angular-cli

ng test does not run tests from new test files when watching

未關閉
#26,470 1 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
area: @angular-devkit/build-angular 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

While `ng test` is running and watching for changes, if you add a new test file, that file is detected and causes the tests to run again, but the tests in that new file are not included in the test run. To include the tests from the new file, you need to restart the `ng test` process.

### Minimal Reproduction

1. In a terminal, run:
```
ng new watch --skip-git --style css --ssr=false
ng test
```

2. Three tests are run.
3. In a second terminal, run:
```
ng g component widget
```

4. A new component is created with a test file that contains one test.
5. The new test file is detected and the tests recompile.
6. **Only three tests are run.**
7. Add another test to the new component's test file.
8. The change is detected and the tests recompile.
9. **Only three tests are run.**
10. Kill the `ng test` process.
11. Run `ng test` again.
12. **Five tests are run.**

### Exception or Error

_No response_

### Your Environment

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

Angular CLI: 17.0.3
Node: 20.9.0
Package Manager: npm 10.1.0
OS: win32 x64

Angular:
...

Package Version
------------------------------------------------------
@angular-devkit/architect 0.1700.3 (cli-only)
@angular-devkit/core 17.0.3 (cli-only)
@angular-devkit/schematics 17.0.3 (cli-only)
@schematics/angular 17.0.3 (cli-only)
```

### Anything else relevant?

Here's a screen recording to help explain what I'm seeing.
![ng-test-watch](https://github.com/angular/angular-cli/assets/10321525/a344aa24-ed17-4b7c-bafb-f788602f19d3)

貢獻指南

開啟貢獻指南

研究方向

使用列出的 `ng new`、`ng test` 和 `ng g component widget` 命令重現該行為,然後追蹤 `ng test` 的 watch 流程,該流程會偵測並重新編譯新的測試檔案。比較初始測試執行與重新啟動後的測試執行;當新加入檔案中的測試能在 watch 期間執行,且不需重新啟動程序時,即視為完成。

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

評估

技術堆疊
angular, typescript
領域
cli, testing
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

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

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