Test a function that contains a setTimeout()
问题 I have a close function in my component that contains a setTimeout() in order to give time for the animation to complete. public close() { this.animate = "inactive" setTimeout(() => { this.show = false }, 250) } this.show is bound to an ngIf . this.animate is bound to an animation. I have a test that needs to test this function it("tests the exit button click", () => { comp.close() fixture.detectChanges() //verifies the element is no longer in the DOM const popUpWindow = fixture.debugElement