Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to to make sinon return non promise I do mock expect

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

     {
        startTimer: () => {}
      }

not wrapped in a promise?

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading