When testing the Barrequest function, an error Expected "fooCall(anything())" to be called 1 time(s). But has been called 0 time(s) is thrown.
//when
const bar = new Bar(commLayer);
bar.request(foo);
//then
verify(MockedFoo.fooCall(anything())).once(); // <---- Error: Expected "fooCall(anything())" to be called 1 time(s). But has been called 0 time(s).
When debugging in the IDE, I see that the resolved promise is executed. I notice console.log(value) displays 'result' in the logs.
Summary
I want to test in a service class that a function is called following a resolved promise.
An error
Expected "fooCall(anything())" to be called 1 time(s). But has been called 0 time(s).
is thrown with the below setup.I've looked in the docs and other issues, but haven't found a solution so far.
Data setup
I want to test the
Bar
service class, that uses a comm. layerCommLayer
and performs a callfooCall
to the UIFoo
Mocking
I am mocking the
CommLayer
andFoo
:Tests
When testing the
Bar
request
function, an errorExpected "fooCall(anything())" to be called 1 time(s). But has been called 0 time(s)
is thrown.When debugging in the IDE, I see that the resolved promise is executed. I notice
console.log(value)
displays 'result' in the logs.Environment