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?
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?
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.
Most of these Jasmine2-related methods are not available anymore. See the Jest documentation for more information on e. g. how to call through spied methods.
Jest by default will use Jasmine2 as test runner, and therefore you can use most (if not all) Jasmine methods.
All of the ones you requested are in Jest available, and.callFake
, as well as and.returnValue
and and.callThrough
.
© 2022 - 2024 — McMap. All rights reserved.
.and.callThrough()
before, we can remove it and it calls the actual function? – Sachasachem