angular / angular/angular-cli

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

Ouverte
#24,345 6 commentaires 5 réactions 0 personnes assignées Voir sur GitHub
area: @angular-devkit/build-angular devkit/build-angular:karma feature feature: insufficient votes
Langage dominant
TypeScript
Étoiles
27k
Forks
11.8k
Merge moyen
14 h 23 min
PR mergées (30 j)
162

Description

### 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$/
});
```

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par suivre la manière dont les options de test de angular.json sont gérées et dont le bootstrap de test.ts est généré ou remplacé. Utilisez les paramètres TestBed demandés et le motif de test personnalisé comme cas d’acceptation ; le travail est terminé lorsque les projets peuvent les configurer sans créer de fichiers test.ts.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
testing, tooling
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.