alternatives to change TestBed configurations without creating the test.ts files
- Vorherrschende Sprache
- TypeScript
- Sterne
- 27k
- Forks
- 11.8k
- Ø Merge
- 14 Std. 23 Min.
- Gemergte PRs (30 T.)
- 162
Beschreibung
### 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$/
});
```
Beitragsleitfaden
Rechercherichtung
Beginne damit nachzuverfolgen, wie Testoptionen in angular.json verarbeitet werden und wie der test.ts-Bootstrap generiert oder ersetzt wird. Verwende die angeforderten TestBed-Einstellungen und das benutzerdefinierte Testmuster als Akzeptanzfälle; fertig ist die Arbeit, wenn Projekte diese konfigurieren können, ohne test.ts-Dateien zu erstellen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- angular, 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