Calling Through
Learn how to use the callThrough and callFake methods.
We'll cover the following...
A Jasmine object spy sits in front of the real object. When our test code calls a method on the underlying object, Jasmine will intercept that call and can take a number of actions. By default, Jasmine uses the stub
strategy, which means it returns undefined
and does not execute the underlying method.
Press + to interact
We can also make use of the callThrough
and callFake
methods:
callThrough
is used to forward a method call to the underlying object. The spy will record the method calls so we can make expectations in our test.
Press + to interact