Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of and.callThrough() in jest-preset-angular

Reading through this link i got to know that the equivalent of

and.callFake is mockImplementation and

and.returnValue is mockReturnValue.

Similarly is there an equivalent of and.callThrough() in jest-preset-angular?

like image 878
radio_head Avatar asked Jan 07 '18 14:01

radio_head


1 Answers

This question may be really old, but tripped me up recently.

Jest, by default, will call the underlying function in a similar manner to .and.callThrough().

This is the opposite behaviour of Jasmine, which blocks the call to the underlying function unless .and.callThrough() is specified.

To block the underlying call in Jest, call the mockImplementation() function.

like image 89
blorkfish Avatar answered Oct 30 '22 23:10

blorkfish