Allow tests to pass without any test files (e.g. via Vitest `passWithNoTests`)
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 72/100
- Issue 類型
- 功能
- 描述清晰度
- 描述清楚
- 活躍度
- 冷清
- 技術堆疊
- angular, typescript
研究方向
從 packages/angular/build/src/builders/unit-test/runners/vitest/build-options.ts 的第 161-170 行附近開始,這裡描述了自訂的無測試檔案檢查。檢視測試命令如何將 runner 選項傳遞給 Vitest,然後驗證沒有測試檔案的專案可以透過 Vitest 的 passWithNoTests 選項成功執行,同時預設行為維持不變。
由索引模型根據 Issue 內容生成。
描述
Command
test
Description
Executing the test command on a project (app or lib) that does not have any test files (yet) will always lead to the following error message:
An exception occurred while getting runner-specific build options:
Error: No tests found matching the following patterns:
- Included: **/*.spec.ts, **/*.test.ts
Please check the 'test' target configuration in your project's 'angular.json' file.
However, many use cases exist where this behaviour is unintended. For example, a freshly generated project (even more so in a monorepo) will often start out without any real test cases defined, and it even may take some time for the first ones to be written. Even at this early point, though, I (as a developer) will usually want to already integrate test execution into a quality gate setup (like continuous integration).
Currently, the Angular CLI does not offer a way to allow the test command to succeed when no test files exist.
Related issue: https://github.com/nrwl/nx/issues/34241
Describe the solution you'd like
The most pragmatic solution would probably be:
- Remove the custom Angular CLI check for test files, see: https://github.com/angular/angular-cli/blob/5adc92541433be23fc2246db5a199cf5c0dc9e67/packages/angular/build/src/builders/unit-test/runners/vitest/build-options.ts#L161-L170
- Instead, rely on Vitest and its
passWithNoTestsoption - which isfalseby default, so no breaking change is to be expected (besides a different log message)
Describe alternatives you've considered
Alternatively:
- The Angular CLI test command could also expose its own option. This would however collide with the respective Vitest option and thus require conflict resolution / priority checks. Plus, skimming the source code leads me to believe that the Angular CLI is currently not actively loading any custom Vite config, just passing it on - so changes here would presumably affect multiple places.
- 主要語言
- TypeScript
- 星號
- 27k
- 分支
- 11.8k
- 平均合併
- 16 小時 21 分鐘
- 30 天內合併 PR
- 170
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
angular/angular-cli 的其他 Issue
-
area: @angular/build gemini-triaged
難度 2/5 1-3 小時 新手友好度 74/100
angular/angular-cli#33955 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 已指派 1 人 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34130 · 已指派 1 人 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34128 · 已指派 1 人 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34124 · 1 則留言 · 已指派 1 人 ·
查看 angular/angular-cli 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 84/100
copse-dev/agent-pane#2953 ·
-
難度 2/5 1-3 小時 新手友好度 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
難度 2/5 1-3 小時 新手友好度 78/100
-
enhancement
難度 2/5 1-3 小時 新手友好度 68/100
-
calcite-components needs triage refactor
難度 2/5 1-3 小時 新手友好度 75/100
Esri/calcite-design-system#15203 ·