Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

jasmine test button click

// Define component and fixture within describe()

it('should click button', fakeAsync(() => {
    spyOn(component, 'methodName');

    let btn = fixture.debugElement.query(By.css('.btn-class'));
    btn.triggerEventHandler('click', null);
    fixture.detectChanges();
    expect(component.methodName).toHaveBeenCalled();
}))
 
PREVIOUS NEXT
Tagged: #jasmine #test #button #click
ADD COMMENT
Topic
Name
3+8 =