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

253
Views
Using sinon withArgs and then try to do a restore I get TypeError: 'restore' is not a function

If I stub my function like so:

const sandbox: sinon.SinonSandbox = sinon.createSandbox();
getInfoStub = sandbox.stub(ytdl, 'getInfo').withArgs(videoUrl).resolves(videoInfo);

And then I try to do getInfoStub.restore() I get a TypeError: getInfoStub.restore is not a function

However when I remove the option .withArgs(videoUrl) restore works fine:

const sandbox: sinon.SinonSandbox = sinon.createSandbox();
getInfoStub = sandbox.stub(ytdl, 'getInfo').resolves(videoInfo);

What's the deal with withArgs that breaks sinon ?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Try below code:

 const getInfoStub = sandbox.stub(ytdl, 'getInfo');
 const result = getInfoStub.withArgs(videoUrl).resolves(videoInfo);
 getInfoStub.restore();

Ref Link: https://sinonjs.org/releases/latest/stubs/

about 4 years ago · Santiago Trujillo 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!