Я просто пытаюсь выполнить эту работу.Angular 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