我已经创建了一个登录页面angular2
.它有两个输入字段as userName
和password
.登录中有一个按钮.当我打算为此编写测试用例时loginComponent
,不得不predicate
用来识别button
.这是我的测试用例.
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { DebugElement } from '@angular/core'; import { LoginComponent } from './login.component'; export class LoginComponentTest { constructor(public loginComponent: LoginComponent){ this.loginComponent.logIn('Chathura', '1234'); } } describe('LoginComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [ LoginComponent ], }) }); const fixture = TestBed.createComponent(LoginComponent); const button = fixture.query(predicate: Predicate, scope?: Function) : DebugElement });
我将通过提供输入值进行测试,然后单击登录按钮,看看接下来会发生什么.
我无法找到正确使用谓词的正确教程.