angular / angular/angular-cli

alternatives to change TestBed configurations without creating the test.ts files

Aperta
#24,345 6 commenti 5 reazioni 0 assegnatari Vedi su GitHub
area: @angular-devkit/build-angular devkit/build-angular:karma feature feature: insufficient votes
Lingua principale
TypeScript
Stelle
27k
Fork
11.8k
Merge medio
14h 23m
PR unite (30g)
162

Descrizione

### Which @angular/* package(s) are relevant/related to the feature request?

core

### Description

with Angular 15, now the `test.ts` file doesn't get generated by default, so it's not an easy task to change the `TestBed` configurations for example to enable `errorOnUnknownElements`
it will also be nice if we can change the pattern of the tests

### Proposed solution

to add the configurations inside the `angular.json` files in the options section of test

something like

```
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": [],
"errorOnUnknownElements": true, <---
"errorOnUnknownProperties": true, <---
"pattern": "\.custom-spec\.ts$" <---
}
```

### Alternatives considered

to be able to enable them globally from any script (to create a js file and add it to the scripts of the test) with something like

```
getTestBed().setoptions({
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
pattern: /\.custom-spec\.ts$/
});
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia tracciando come vengono gestite le opzioni di test di angular.json e come viene generato o sostituito il bootstrap di test.ts. Usa le impostazioni TestBed richieste e il pattern di test personalizzato come casi di accettazione; il lavoro è completato quando i progetti possono configurarli senza creare file test.ts.

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

Valutazione

Stack tecnologico
angular, 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.