나는이 작업을하려고하고 있습니다.각도 2 : 테스트에서 템플릿이 업데이트되지 않음
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!");
그래서, runMe
기능 섹션의 텍스트를 변경하지 않은,하지만 스파이 runMe
가 호출을 보여줍니다.
'runMe' 기능을위한 코드를 포함하도록 게시물을 편집 할 수 있습니까? – jhhoff02