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

91
Views
Broma: objeto simulado utilizado dentro de la función probada

Me gustaría burlarme de un objeto utilizado en el interior llamado función probada. Todo lo que encontré fue que otros boletos estaban llamando a la función en la función probada, pero necesito reemplazar cierto objeto que se usa allí. ¿Es algo así posible en Jest?

util.test.js

 describe('testname', function () { it('import test', function () { Utils.generateRandomPoints(10); // inside this function, I'd like to mock used object }); });

utils.js

 export function generateRandomPoints(arrayLength) { const result = []; for (let i = 0; i < 100; i++) { // instead of "new Point" I'd like to use "new MockedPoint" for testing. result.push(new Point(i)); } return result; };
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!