Не удается найти ошибку интерфейса при выполнении теста Жасмин - PullRequest
0 голосов
/ 20 октября 2019

Я создал тест в своем угловом 8 приложении. Я получаю «не могу найти ошибку интерфейса» во время выполнения теста. Тест - это простой тест, который просто проверяет, верен ли компонент. Я не уверен, почему получаю сообщение «Не могу найти ошибку интерфейса при выполнении только теста».

Я получаю следующие ошибки

ERROR in src/app/customer/customer.component.ts:13:26 - error TS2304: Cannot find name 'ICustomer'.

customers$: Observable<ICustomer[]>;
                            ~~~~~~~~~
src/app/services/customer.service.ts:12:31 - error TS2304: Cannot find name 'ICustomer'.

getCustomers() : Observable<ICustomer[]>{

test

describe('CustomerComponent', () => {
  let component: CustomerComponent;
  let fixture: ComponentFixture<CustomerComponent>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ CustomerComponent ],
      providers: [CustomerService]
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(CustomerComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});

Клиентский компонент

export class CustomerComponent implements OnInit {
  customers$: Observable<ICustomer[]>;
  errorMessage: any;


  constructor(private customerService: CustomerService) { }

  ngOnInit() {
      this.customers$ = this.customerService.getCustomers()
          .pipe(
              catchError(err => {
                 this.errorMessage = err;
                 return EMPTY;
              })
          )
  }


}

Обслуживание клиентов

export class CustomerService {

  constructor(private smartTrCommonService:  SmartTrCommonService) { }

  getCustomers() : Observable<ICustomer[]>{
    return this.smartTrCommonService.httpGet('/api/customers/');
  }
}

Интерфейс клиента

interface ICustomer {

        customerId : string;
        companyName : string;
        contactName : string;
        contactTitle : string;
        address : string;
        city : string;
        region : string;
        postalCode : string;
        country : string;
        phone : string;
        fax : string;

}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...