Description
Command
test
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
19
Description
I was in the middle of migration from v19 to v20 for our ui-kit library. It went OK but then I tried to run unit tests and some of them failed because they're trying to load a 3rd party script. So basically this simplified piece of code was throwing an error
loadScript() {
return new Observable<void>(obs => {
const script = document.createElement("script");
script.src = "test.js";
script.onload = () => {
obs.next();
obs.complete();
}
script.onerror = () => {
obs.error();
obs.complete();
}
document.body.appendChild(script);
})
}
We have a config for the script file in angular.json
. Here it is (I just renamed it for the sake of simplicity)
"scripts": [
{
"input": "src/test.js",
"bundleName": "test",
"inject": false
}
]
This works fine in v19 but doesn't in v20.
Minimal Reproduction
I created two repos with a unit test which tries to load a script
- v19 https://github.com/ms-dosx86/test-v19 (passes)
- v20 https://github.com/ms-dosx86/test-v20 (doesn't pass)
Just run ng test
.
Exception or Error
Your Environment
Angular CLI: 20.0.4
Node: 22.12.0
Package Manager: npm 10.9.0
OS: darwin arm64
Angular: 20.0.5
... common, compiler, compiler-cli, core, forms
... platform-browser, router
Package Version
------------------------------------------------------
@angular-devkit/architect 0.2000.4
@angular-devkit/core 20.0.4
@angular-devkit/schematics 20.0.4
@angular/build 20.0.4
@angular/cli 20.0.4
@schematics/angular 20.0.4
rxjs 7.8.2
typescript 5.8.3
zone.js 0.15.1
Anything else relevant?
No response