I am just trying to make this work.
it('should have expected <h1> text', async(() => {
let fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const sectionEl = fixture.debugElement.query(By.css("section"));
spyOn(fixture.debugElement.componentInstance, "runMe");
sectionEl.nativeElement.click();
expect(fixture.debugElement.componentInstance.runMe).toHaveBeenCalled();
expect(sectionEl.nativeElement.textContent).toBe("changed!");
So, the runMe
function did not change the section's text, but the spy shows runMe
was called.