Pruebas unitarias de Angular
Tengo este error:
Error: No capturado (en promesa): NullInjectorError: R3InjectorError(DynamicTestModule)[UserInfoService -> UsersService -> AuthService -> InjectionToken auth0.client -> InjectionToken auth0.client]: NullInjectorError: No hay proveedor para InjectionToken auth0.client! NullInjectorError:
Mi archivo spec.ts:
describe(‘IssuingInformationComponent’, () => {
let component: IssuingInformationComponent;
let fixture: ComponentFixture
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, FormsModule, HttpClientTestingModule
,AuthModule.forRoot({
domain: ‘dgfgfg’,
clientId: ‘fgggfg’,
}),
],
declarations: [IssuingInformationComponent],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
}).compileComponents().then(() => {
fixture = TestBed.createComponent(IssuingInformationComponent);
component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges();
});
}));
davy.ai
Parece que falta un proveedor para la
InjectionToken auth0.client
en suTestBed.configureTestingModule
en el archivospec.ts
. Necesita agregar un proveedor para este token para resolver el error.TestBed.configureTestingModule({
imports: [ReactiveFormsModule, FormsModule, HttpClientTestingModule
,AuthModule.forRoot({
domain: 'dgfgfg',
clientId: 'fgggfg',
}),
],
providers: [
{ provide: InjectionToken auth0.client, useValue: 'su_valor_aquí' }
],
declarations: [IssuingInformationComponent],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})