Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

58
Views
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

     {
        startTimer: () => {}
      }

not wrapped in a promise?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!