Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular: HttpClientTestingModule is deprecated #26511

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
limitations under the License.
-%>
import { TestBed, waitForAsync, tick, fakeAsync, inject } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { ActivatedRoute } from '@angular/router';
import { of, throwError } from 'rxjs';

Expand All @@ -30,8 +30,9 @@ describe('ActivateComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, ActivateComponent],
imports: [ActivateComponent],
providers: [
provideHttpClient(),
{
provide: ActivatedRoute,
useValue: { queryParams: of({ key: 'ABC123' }) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
limitations under the License.
-%>
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClientTesting, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';

import { ActivateService } from './activate.service';
import { ApplicationConfigService } from 'app/core/config/application-config.service';
Expand All @@ -29,7 +30,7 @@ describe('ActivateService Service', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [provideHttpClient(), provideHttpClientTesting()],
});

service = TestBed.inject(ActivateService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-%>
import { ElementRef, signal } from '@angular/core';
import { ComponentFixture, TestBed, inject, tick, fakeAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { FormBuilder } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { of, throwError } from 'rxjs';
Expand All @@ -32,8 +32,9 @@ describe('PasswordResetFinishComponent', () => {

beforeEach(() => {
fixture = TestBed.configureTestingModule({
imports: [HttpClientTestingModule, PasswordResetFinishComponent],
imports: [PasswordResetFinishComponent],
providers: [
provideHttpClient(),
FormBuilder,
{
provide: ActivatedRoute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
limitations under the License.
-%>
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClientTesting, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';

import { PasswordResetFinishService } from './password-reset-finish.service';
import { ApplicationConfigService } from 'app/core/config/application-config.service';
Expand All @@ -29,7 +30,7 @@ describe('PasswordResetFinish Service', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [provideHttpClient(), provideHttpClientTesting()],
});

service = TestBed.inject(PasswordResetFinishService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-%>
import { ElementRef, signal } from '@angular/core';
import { ComponentFixture, TestBed, inject } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { FormBuilder } from '@angular/forms';
import { of, throwError } from 'rxjs';

Expand All @@ -31,8 +31,8 @@ describe('PasswordResetInitComponent', () => {

beforeEach(() => {
fixture = TestBed.configureTestingModule({
imports: [HttpClientTestingModule, PasswordResetInitComponent],
providers: [FormBuilder],
imports: [PasswordResetInitComponent],
providers: [provideHttpClient(), FormBuilder],
})
.overrideTemplate(PasswordResetInitComponent, '')
.createComponent(PasswordResetInitComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
limitations under the License.
-%>
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClientTesting, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';

import { PasswordResetInitService } from './password-reset-init.service';
import { ApplicationConfigService } from 'app/core/config/application-config.service';
Expand All @@ -29,7 +30,7 @@ describe('PasswordResetInit Service', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [provideHttpClient(), provideHttpClientTesting()],
});

service = TestBed.inject(PasswordResetInitService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
jest.mock('app/core/auth/account.service');

import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { HttpResponse, provideHttpClient } from '@angular/common/http';
import { FormBuilder } from '@angular/forms';
import { of, throwError } from 'rxjs';

Expand All @@ -37,8 +36,8 @@ describe('PasswordComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, PasswordComponent],
providers: [FormBuilder, AccountService],
imports: [PasswordComponent],
providers: [FormBuilder, AccountService, provideHttpClient()],
})
.overrideTemplate(PasswordComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClientTesting, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';

import { PasswordService } from './password.service';
import { ApplicationConfigService } from 'app/core/config/application-config.service';
Expand All @@ -11,7 +12,7 @@ describe('Password Service', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [provideHttpClient(), provideHttpClientTesting()],
});

service = TestBed.inject(PasswordService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
limitations under the License.
-%>
import { ComponentFixture, TestBed, waitForAsync, inject, tick, fakeAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { FormBuilder } from '@angular/forms';
import { of, throwError } from 'rxjs';
<%_ if (enableTranslation) { _%>
Expand All @@ -40,10 +40,9 @@ describe('RegisterComponent', () => {
<%_ if (enableTranslation) { _%>
TranslateModule.forRoot(),
<%_ } _%>
HttpClientTestingModule,
RegisterComponent,
],
providers: [FormBuilder],
providers: [provideHttpClient(), FormBuilder],
})
.overrideTemplate(RegisterComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
limitations under the License.
-%>
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClientTesting, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';

import { RegisterService } from './register.service';
import { ApplicationConfigService } from 'app/core/config/application-config.service';
Expand All @@ -30,7 +31,7 @@ describe('RegisterService Service', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [provideHttpClient(), provideHttpClientTesting()],
});

service = TestBed.inject(RegisterService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
jest.mock('app/core/auth/account.service');

import { ComponentFixture, TestBed, inject, tick, fakeAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { of, throwError } from 'rxjs';

import { AccountService } from 'app/core/auth/account.service';
Expand All @@ -46,8 +46,8 @@ describe('SessionsComponent', () => {

beforeEach(() => {
fixture = TestBed.configureTestingModule({
imports: [HttpClientTestingModule, SessionsComponent],
providers: [AccountService],
imports: [SessionsComponent],
providers: [provideHttpClient(), AccountService],
})
.overrideTemplate(SessionsComponent, '')
.createComponent(SessionsComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
jest.mock('app/core/auth/account.service');

import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { FormBuilder } from '@angular/forms';
import { throwError, of } from 'rxjs';
<%_ if (enableTranslation) { _%>
Expand Down Expand Up @@ -53,10 +53,9 @@ describe('SettingsComponent', () => {
<%_ if (enableTranslation) { _%>
TranslateModule.forRoot(),
<%_ } _%>
HttpClientTestingModule,
SettingsComponent,
],
providers: [FormBuilder, AccountService],
providers: [provideHttpClient(), FormBuilder, AccountService],
})
.overrideTemplate(SettingsComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
limitations under the License.
-%>
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { of } from 'rxjs';

import ConfigurationComponent from './configuration.component';
Expand All @@ -32,8 +32,8 @@ describe('ConfigurationComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, ConfigurationComponent],
providers: [ConfigurationService],
imports: [ConfigurationComponent],
providers: [provideHttpClient(), ConfigurationService],
})
.overrideTemplate(ConfigurationComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
limitations under the License.
-%>
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClientTesting, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';

import { ConfigurationService } from './configuration.service';
import { Bean, ConfigProps, Env, PropertySource } from './configuration.model';
Expand All @@ -29,7 +30,7 @@ describe('Logs Service', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [provideHttpClient(), provideHttpClientTesting()],
});

expectedResult = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
limitations under the License.
-%>
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpErrorResponse } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient, HttpErrorResponse } from '@angular/common/http';
import { of, throwError } from 'rxjs';

import HealthComponent from './health.component';
Expand All @@ -33,7 +32,8 @@ describe('HealthComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, HealthComponent],
imports: [HealthComponent],
providers: [provideHttpClient()],
})
.overrideTemplate(HealthComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
limitations under the License.
-%>
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClientTesting, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';

import { HealthService } from './health.service';
import { ApplicationConfigService } from 'app/core/config/application-config.service';
Expand All @@ -29,7 +30,7 @@ describe('HealthService Service', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [provideHttpClient(), provideHttpClientTesting()],
});

service = TestBed.inject(HealthService);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';

import HealthModalComponent from './health-modal.component';
Expand All @@ -12,8 +12,8 @@ describe('HealthModalComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, HealthModalComponent],
providers: [NgbActiveModal],
imports: [HealthModalComponent],
providers: [provideHttpClient(), NgbActiveModal],
})
.overrideTemplate(HealthModalComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
limitations under the License.
-%>
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { of } from 'rxjs';

import LogsComponent from './logs.component';
Expand All @@ -35,8 +36,8 @@ describe('LogsComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, LogsComponent],
providers: [LogsService<%= applicationTypeGateway && serviceDiscoveryAny ? ', GatewayRoutesService' : '' %>],
imports: [LogsComponent],
providers: [provideHttpClient(), provideHttpClientTesting(), LogsService<%= applicationTypeGateway && serviceDiscoveryAny ? ', GatewayRoutesService' : '' %>],
})
.overrideTemplate(LogsComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
limitations under the License.
-%>
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClientTesting, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';

import { LogsService } from './logs.service';

Expand All @@ -27,7 +28,7 @@ describe('Logs Service', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [provideHttpClient(), provideHttpClientTesting()],
});

service = TestBed.inject(LogsService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
limitations under the License.
-%>
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';

import { MetricsModalThreadsComponent } from './metrics-modal-threads.component';
Expand All @@ -30,8 +30,8 @@ describe('MetricsModalThreadsComponent', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, MetricsModalThreadsComponent],
providers: [NgbActiveModal],
imports: [MetricsModalThreadsComponent],
providers: [provideHttpClient(), NgbActiveModal],
})
.overrideTemplate(MetricsModalThreadsComponent, '')
.compileComponents();
Expand Down
Loading
Loading