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

185
Views
El servidor falso de Sinon no responde cuando se invocan las API desde una devolución de llamada de setTimeout

Como el título de esta pregunta dice que el servidor falso sinon no responde a las llamadas API/ajax realizadas desde una devolución de llamada de setTimeOut.

Estado.js

 _checkStatus() { if (...) { .... } } else if (...) { .... } else { setTimeout(async () => { this.status = await services.getStatus(); this._checkStatus(); },100); } }

Estado.prueba.js

 const API_STATUS = /\/status/; const cType = { 'Content-Type': 'application/json' }; const mocks = {}; mocks.get = { code: 'ready' }; const server = fakeServer.create(); server.respondImmediately = true; server.respondWith(API_STATUS, [200, cType, JSON.stringify(mocks.get)]); el._checkStatus(); setTimeout(function(done){ expect(el.status).to.equal('ready'); done(); } ,500); });

Cuando ejecutamos esta prueba, invoca los simulacros que están definidos en la carpeta del repositorio pero no detecta el simulacro de servidor falso definido anteriormente. Sin embargo, si muevo la llamada getStatus() fuera del tiempo de espera, entonces funciona con un servidor falso. Solo un FYI que getStatus() invoca la llamada API de estado.

about 4 years ago · Juan Pablo Isaza
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!