Allow tests to pass without any test files (e.g. via Vitest `passWithNoTests`)

未关闭 适合新手
#33,055 1 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
冷清
技术栈
angular, typescript
领域
cli, testing

调研方向

从 packages/angular/build/src/builders/unit-test/runners/vitest/build-options.ts 的第 161-170 行附近开始,这里描述了自定义的无测试文件检查。检查测试命令如何将 runner 选项传递给 Vitest,然后验证没有测试文件的项目可以通过 Vitest 的 passWithNoTests 选项成功运行,同时默认行为保持不变。

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

描述

area: @angular/cli gemini-triaged
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:

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

angular/angular-cli 的其他 Issue

查看 angular/angular-cli 的全部 Issue

把新 issue 发到你的邮箱

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