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

101
Views
¿Cómo burlarse de la llamada ajax en jamine?

Estoy tratando de burlarme del ajax pero no funciona. He intentado varias cosas pero no ayuda.

el escenario del código es como. Nombre de archivo: prueba.js

 import {ajax} from 'jquery'; const someFunction = param => new Promise((resolve) => { ajax({ method: 'GET', cache: false, url: `someurl/url`, success: (response) => { resolve(response); }, error: () => resolve(null), }); }); export {someFunction}

y está llamando a otra función como esta

 testCall() { // some codes someFunction(param).then((response) => { // codes }) }

He tratado de burlarme como estas 3 formas

 spyOn($, 'ajax').and.callFake( () =>{ var d = $.Deferred(); d.resolve({}); return d.promise(); }); -------------- spyOn($, 'ajax').and.callFake( (promise) => { var d = $.Deferred(); d.reject(promise.success()); return d.promise(); }); ------------- const testing = new Promise((resolve) => { spyOn(test, 'someFunction').and.callFake(() => { // here test is import form test.js file resolve(); return fakeResponse; }); })

Cualquier ayuda sería apreciada.

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!