I am using sinon to mock a return for a function and here is my code:
sandbox.mock(monitoring).expects('getHttpRequestDuration').resolves({
startTimer: () => {}
});
The problem here is the return is wrapped in a promise and the actual function is not using any await
const end = httpRequestTimer.startTimer();
is there a way I can return only
{
startTimer: () => {}
}
not wrapped in a promise?
resolves
returns a promise. The equivalent method in sinon to return a value is .returns
:
sandbox.mock(monitoring).expects('getHttpRequestDuration').returns({
startTimer: () => {}
});
See stub.returns
in our docs.