Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Geschlossen
#34,385 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Ein zugehöriger Pull Request wurde bereits gemerged.

  • #34386 von @MeAkib — gemerged

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
angular, typescript
Bereich
testing

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
1 T. 6 Std.
Gemergte PRs (30 T.)
224

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus angular/angular-cli

Alle Issues in angular/angular-cli

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.