Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

90
Vistas
Jest: mock object used inside tested function

I would like to mock an object used inside called tested function. All I have found I another tickets was calling function in tested function, but I need to replace certain object that is used there. Is something like that possible in 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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda