Angular testing how to prevent ngOnInit call to test a method directly

前端 未结 3 1774
天命终不由人
天命终不由人 2020-12-24 02:35

Context

I have a component. Inside of it, the ngOnInit function calls another function of component to retrieve user List. I want to make two series of tets:

3条回答
  •  再見小時候
    2020-12-24 03:01

    I personally prefer cancelling the component ngOnInit for every test.

    beforeEach(() => { UserListComponent.prototype.ngOnInit = () => {} ; .... });

提交回复
热议问题