angular / angular/angular-cli

Schematics testing infrastructure: ability to easily bootstrap a Tree

未关闭
#12,706 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
area: @angular-devkit/schematics feature feature: insufficient votes
主要语言
TypeScript
星标
27k
派生
11.8k
平均合并
14 小时 23 分钟
30 天内合并 PR
162

描述

### Bug Report or Feature Request (mark with an `x`)
```
- [ ] bug report -> please search issues before submitting
- [x] feature request
```

### Desired functionality

I'd like to be able to more easily unit test individual Rules. and to do this, I'd like to be able to easily create a Tree on the fly.

My current strategy is to create a new schematic for the sole purpose of testing. But there is quite a bit of boilerplate that goes into this: the schematic code, the schema, the build rules, the awkward dependency of the test on this schematic, and the construction of a new schematicRunner in the test. Furthermore, different Rules need different Tree "boilerplate" for testing, so instead of creating a new schematic for each, I've just been jamming all the different types of files I need into this one test-only schematic, which is becoming unwieldy - which files are for testing which Rules?

Sometimes, I am testing a really simple Rule that only operates on one file, and I just want to be able to ask some function: "give me a tree with one file at this certain path with this certain content" or "give me a tree with an empty file at this path" and so on.

I think it'd be great if there was some testing infrastructure that could cook up a quick Tree in place. Or - does something like this already exist?

贡献指南

打开贡献指南

调研方向

首先阅读现有的仅用于测试的 Schematic 设置,包括其 Schematic 代码、schema、构建规则以及测试中 SchematicRunner 的构造。比较各个 Rules 使用的不同 Tree 样板,并定义一个能够创建所请求文件和内容的小型测试入口点;当 Rules 无需专用 Schematic 即可进行单元测试时,即表示完成。

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

评估

技术栈
typescript
领域
testing, tooling
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

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