`urlRoot` in `karma.conf.js` can't be set to anything other than the default `/`
- Vorherrschende Sprache
- TypeScript
- Sterne
- 27k
- Forks
- 11.8k
- Ø Merge
- 14 Std. 23 Min.
- Gemergte PRs (30 T.)
- 162
Beschreibung
# 🐞 Bug report
### Command (mark with an `x`)
- [ ] new
- [ ] build
- [ ] serve
- [x] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] extract-i18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
### Is this a regression?
No.
### Description
Can't set `urlRoot` in `karma.conf.js` to anything other than "/" because:
> Angular CLI uses custom context file, which leads to this bug. It adds ``, which forces context.html to request http://localhost:9876/context.js instead of http://localhost:9876/karma/context.js.
which is described in detail in this issue: https://github.com/karma-runner/karma/issues/3357#issuecomment-634630974.
## 🔬 Minimal Reproduction
Run `ng test` with a `karma.conf.js` that contains a `urlRoot` set to anything but `/`:
```js
{
...,
urlRoot: "newBase"
}
```
## 🔥 Exception or Error
The error that is logged is the following:
```
09 11 2021 23:25:29.766:WARN [web-server]: 404: /_karma_webpack_/context.js
```
## 🌍 Your Environment
Angular CLI: 11.2.0
Node: 14.18.0
OS: darwin x64
Angular: 11.2.14
... common, compiler, compiler-cli, core, forms, localize
... platform-browser, platform-browser-dynamic, router, upgrade
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1102.0
@angular-devkit/build-angular 0.1102.0
@angular-devkit/core 11.2.14
@angular-devkit/schematics 11.2.14
@angular/animations 12.2.8
@angular/cdk 11.2.13
@angular/cli 11.2.0
@schematics/angular 11.2.14
@schematics/update 0.1102.0
rxjs 6.6.7
typescript 4.1.6
Beitragsleitfaden
Rechercherichtung
Beginne mit karma.conf.js und dem ng test-Einstiegspunkt und verwende die gezeigte urlRoot-Konfiguration, um den Fehler zu reproduzieren. Verfolge, wie die benutzerdefinierte Context-Datei context.js auflöst, wenn urlRoot auf newBase gesetzt ist, und vergleiche dies mit dem erwarteten Pfad /karma/context.js. Als erledigt gilt die Ausführung des Tests, wenn das Context-Skript unter der konfigurierten urlRoot ohne einen 404 angefordert wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- angular, javascript, typescript
- Bereich
- testing
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100