-
Notifications
You must be signed in to change notification settings - Fork 27k
Description
Command
update
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
Running ng update on an Angular 17 project with unit tests containing both HttpClientModule and HttpClientTestingModule. Result of the "Replace deprecated HTTP modules with provider functions" schematics is invalid.
Before:
import { HttpClientModule } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
describe('AppComponent', () => {
beforeEach(async (): void => {
await TestBed.configureTestingModule({
imports: [
HttpClientModule,
HttpClientTestingModule,
AppComponent,
],
providers: [
],
}).compileComponents();
});
});
After:
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
describe('AppComponent', () => {
beforeEach(async (): void => {
await TestBed.configureTestingModule({
imports: [HttpClientModule,
AppComponent],
providers: [
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting()
]
}{
imports: [HttpClientTestingModule,
AppComponent],
providers: [
provideHttpClient(withInterceptorsFromDi())
]
}).compileComponents();
});
}
});
Expected result would be TestBed.configureTestingModule with single object inside and replaced deprecated modules with provider functions
Minimal Reproduction
- command run:
npx @angular/cli@17 new angular-18-migration-issues - Use both
HttpClientModuleandHttpClientTestingModuleinTestBed.configureTestingModule - command run:
ng update @angular/core@18 @angular/cli@18
Exception or Error
No response
Your Environment
Angular CLI: 18.2.8
Node: 22.11.0
Package Manager: npm 10.9.0
OS: darwin arm64
Angular: 18.2.8
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
@angular-devkit/architect 0.1802.8
@angular-devkit/build-angular 18.2.8
@angular-devkit/core 18.2.8
@angular-devkit/schematics 18.2.8
@schematics/angular 18.2.8
rxjs 7.8.1
typescript 5.5.4
zone.js 0.14.10
Anything else relevant?
No response