Open piyush2311 opened 6 years ago
I get an error when testing too.
TypeError: Cannot read property 'handleError' of null
TypeError: Cannot read property 'handleError' of null
at CatchSubscriber.eval [as selector] (./src/sdk/services/core/base.service.ts?:165:257)
at CatchSubscriber.error (./node_modules/rxjs/_esm5/internal/operators/catchError.js?:40:31)
at MapSubscriber.Subscriber._error (./node_modules/rxjs/_esm5/internal/Subscriber.js?:93:26)
at MapSubscriber.Subscriber.error (./node_modules/rxjs/_esm5/internal/Subscriber.js?:71:18)
at FilterSubscriber.Subscriber._error (./node_modules/rxjs/_esm5/internal/Subscriber.js?:93:26)
at FilterSubscriber.Subscriber.error (./node_modules/rxjs/_esm5/internal/Subscriber.js?:71:18)
at MergeMapSubscriber._tryNext (./node_modules/rxjs/_esm5/internal/operators/mergeMap.js?:74:30)
at MergeMapSubscriber._next (./node_modules/rxjs/_esm5/internal/operators/mergeMap.js?:61:18)
at MergeMapSubscriber.Subscriber.next (./node_modules/rxjs/_esm5/internal/Subscriber.js?:65:18)
at Observable.eval [as _subscribe] (./node_modules/rxjs/_esm5/internal/observable/scalar.js?:8:20)
Process finished with exit code 0
Test looks like this:
describe('SearchFormExpScreenComponent', () => {
let component: SearchFormExpScreenComponent;
let fixture: ComponentFixture<SearchFormExpScreenComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [FormsModule],
declarations: [SearchFormExpScreenComponent],
providers: [ExpScreenApi, ExpScreenUploadWorkflowApi, HttpClient,
HttpHandler, SocketConnection, SocketDriver, SDKModels, LoopBackAuth, InternalStorage],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SearchFormExpScreenComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
}
I have the most recent versions of the SDK Builder, angular and karma installed.
I'm still fairly new to angular. Anyone have any experience mocking these api calls they'd like to share? ;-)
Its a possible bug in the error class. This:
export class ErrorHandler {
public handleError(errorResponse: HttpErrorResponse): Observable<never> {
return throwError(errorResponse.error.error || 'Server error');
}
}
Should be:
export class ErrorHandler {
public handleError(errorResponse: HttpErrorResponse): Observable<never> {
return throwError(errorResponse.error || 'Server error');
}
}
I am writing unit test code for member login and signup API in angular 5 but I am not able to do as well please provide a solution for that how can I do a unit test with angular 5 with loopback-sdk-builder
login.component.spec.ts
login.component.ts