describe('BannerComponent (inline template)', () => {
let comp: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
let de: DebugElement;
let el: HTMLElement;
it('should display original title', () => {
fixture.detectChanges();
expect(el.textContent).toContain(comp.signIn);
});
it('should display a different test title', () => {
comp.signIn = 'Test Title';
fixture.detectChanges();
expect(el.textContent).toContain('Test Title');
});
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ LoginComponent ], // declare the test component
});
fixture = TestBed.createComponent(LoginComponent);
comp = fixture.componentInstance; // BannerComponent test instance
// query for the title <h1> by CSS element selector
de = fixture.debugElement.query(By.css('./login.component.scss'));
el = de.nativeElement;
});
以上是我写的代码,但我面临的错误如
类型的参数&#39;(userName:any,password:any)=&gt;空隙&#39;不能分配给&#39;预期&#39;类型的参数。 输入&#39;(userName:any,密码:any)=&gt;空隙&#39;不能分配给&#39; ObjectContaining&#39;。 物业&#39; jasmineMatches&#39;类型&#39;中缺少(userName:any,密码:any)=&gt;空隙&#39;
答案 0 :(得分:0)
最新版本的Typescript / Jasmine的已知问题。尝试现在明确指定Typescript的包版本,可能是2.1.6。