无法读取角度测试中未定义的属性句柄

时间:2020-05-18 06:35:07

标签: javascript angularjs typescript

I'm getting below error in my test

我正在尝试为角度编写测试,并且遇到了以下错误,例如“无法读取未定义的属性句柄”。不确定如何喜欢它

// data.service.spec.ts
    service = new DataService(httpClient, appConfigService,erroService);
    TestBed.configureTestingModule({
        imports: [HttpClientTestingModule],
        providers: 
          [
              { provide: DataService, useValue: service },
              { provide:AppConfigService, useValue : appConfigService},
              { provide:HttpClient, useValue : httpClient}
        ]
      });
      injector = getTestBed();
       service= injector.get(DataService);
       })
     // my test
      it('should On Board a new customer',done=>{
     var response =service.onboardCustomer(customer);
     response.subscribe(res=> {
      expect(res.UserID).toBeGreaterThan(0);
    })
   // DataService.ts


    public onboardCustomer(customer: ICustomer): Observable<IOnboardingResponse> {
    const model: IOnboardingRequest = {
      userID: customer.userrID,
      userNumber: customer.userId,

    };

    return this.http.post<IOnboardingResponse>(`${this.api}/v1/data/users`, model).pipe(
      tap(() => {
        this.updateCustomerList$().subscribe();
      })
    );
  }

0 个答案:

没有答案
相关问题