Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

`ng generate web-worker` adds `webWorkerTsConfig` to the `@angular/build:unit-test` target, breaking `ng test`

Fermée
#34,385 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Une pull request liée a déjà été fusionnée.

  • #34386 par @MeAkib — fusionnée

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
angular, typescript
Domaine
testing

Piste de recherche

Read packages/schematics/angular/web-worker/index.ts and inspect the logic that adds webWorkerTsConfig to the test target. Compare the supported test builders with the unit-test builder’s options, then check the schematic spec mentioned in the issue’s proposed fix. Done means generating a web worker leaves ng test --watch=false passing for a new application.

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

Description

area: @schematics/angular
Command

generate

Is this a regression?
  • Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was

No response

Description
Image

Running ng generate web-worker in a newly created application breaks ng test.

The web-worker schematic adds webWorkerTsConfig to the options of the project's test target, regardless of
which builder that target uses. New applications use the @angular/build:unit-test builder, whose schema does not
have a webWorkerTsConfig option, so ng test fails schema validation afterwards.

The option is still needed on the build target (where the schematic also adds it). Removing it from the test
target makes ng test pass again, including with the worker in place.

Relevant code: packages/schematics/angular/web-worker/index.ts

if (testTarget) {
  (testTarget.options ??= {}).webWorkerTsConfig ??= workerConfigPath;
}
Minimal Reproduction
  1. ng new ww-repro --defaults
  2. cd ww-repro
  3. ng test --watch=false → passes
  4. ng generate web-worker app
  5. ng test --watch=false → fails with the error below

After step 4, the test target in angular.json is:

"test": {
  "builder": "@angular/build:unit-test",
  "options": {
    "webWorkerTsConfig": "tsconfig.worker.json"
  }
}

Deleting webWorkerTsConfig from the test target options makes ng test pass again.

Exception or Error
Error: Schema validation failed with the following errors:
  Unknown option "webWorkerTsConfig". Valid options are: buildTarget, tsConfig, runner, runnerConfig, browsers, browserViewport, include, exclude, filter, watch, headless, debug, ui, isolate, splitting, quiet, coverage, coverageInclude, coverageExclude, coverageReporters, coverageThresholds, coverageWatermarks, reporters, outputFile, providersFile, setupFiles, progress, listTests, dumpVirtualFiles.
Your Environment
Angular CLI       : 22.2.3
Node.js           : 24.15.0
Package Manager   : npm 11.12.1
OS                : darwin arm64
@angular/build    : 22.2.3
vitest            : 5.0.5
Anything else relevant?

Suggested fix: only add webWorkerTsConfig to the test target when it uses a Karma builder
(@angular-devkit/build-angular:karma / @angular/build:karma). The unit-test builder gets build options from
its buildTarget. Happy to send a PR with a spec.

Langage dominant
TypeScript
Étoiles
27k
Forks
11.8k
Merge moyen
1 j 6 h
PR mergées (30 j)
224

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de angular/angular-cli

Toutes les issues de angular/angular-cli

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

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