angular / angular/angular-cli

Schematics testing infrastructure: ability to easily bootstrap a Tree

Offen
#12,706 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
area: @angular-devkit/schematics feature feature: insufficient votes
Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
14 Std. 23 Min.
Gemergte PRs (30 T.)
162

Beschreibung

### 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?

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem Lesen der bestehenden, nur für Tests gedachten Schematic-Einrichtung einschließlich ihres Schematic-Codes, Schemas, Build-Regeln und des Aufbaus von SchematicRunner im Test. Vergleiche die unterschiedlichen Tree-Boilerplates, die von einzelnen Rules verwendet werden, und definiere einen kleinen Test-Einstiegspunkt, der die angeforderten Dateien und Inhalte erstellen kann; fertig ist dies, wenn Rules ohne eine dedizierte Schematic per Unit-Tests getestet werden können.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
testing, tooling
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.