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 摘要。