我对使用Jasmine和Karma的5角单元测试存在问题.
错误是:"无法绑定到'fruits',因为它不是'my-component2'的已知属性".
单元测试代码是:
SRC /应用/组件/我-COMPONENT1 /我-component1.component.spec.ts:
import { TestBed, inject, ComponentFixture, async} from '@angular/core/testing';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import { Post } from '../../models/post.model';
import { MyComponent1Component } from './my-component1.component';
import { MyService1Service } from '../../services/my-service1.service';
import { HttpClientModule, HttpClient,HttpHandler } from '@angular/common/http';
import {fruit} from '../../Models/fruit';
fdescribe('MyComponent1Component', () => {
let component: MyComponent1Component;
let fixture: ComponentFixture<MyComponent1Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MyComponent1Component ],
imports: [],
providers: [MyService1Service, HttpClient, HttpHandler, HttpTestingController]
})
.compileComponents();
}));
beforeEach(async(() => {
fixture …Run Code Online (Sandbox Code Playgroud)