angular / angular/angular-cli

Schematics testing infrastructure: ability to easily bootstrap a Tree

Aperta
#12,706 2 commenti 1 reazione 0 assegnatari Vedi su GitHub
area: @angular-devkit/schematics feature feature: insufficient votes
Lingua principale
TypeScript
Stelle
27k
Fork
11.8k
Merge medio
14h 23m
PR unite (30g)
162

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia leggendo la configurazione esistente di Schematic dedicata solo ai test, compresi il relativo codice Schematic, lo schema, le regole di build e la costruzione di SchematicRunner del test. Confronta i diversi boilerplate di Tree utilizzati dalle singole Rules e definisci un piccolo punto di ingresso per i test in grado di creare i file e il contenuto richiesti; il lavoro è completato quando le Rules possono essere sottoposte a unit test senza uno Schematic dedicato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
testing, tooling
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.