Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#24,345 6 commenti 5 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

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

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.

Descrizione

area: @angular-devkit/build-angular devkit/build-angular:karma feature feature: insufficient votes
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$/
});
Lingua principale
TypeScript
Stelle
27k
Fork
11.8k
Merge medio
16h 35m
PR unite (30g)
176

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di angular/angular-cli

Tutte le issue di angular/angular-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.