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

161
Vistas
Mocha tests doesn't recognize object's functions

I'm trying to build javascript unit tests using mocha framework and I get the following error: 'x is not a function'. One of my tests executes some functions and one of my inner functions calls to Logger.info(), then it raises an exception because it doesn't recognize info as a function. When I debug it, the debug console do recognize the object Logger and it's properties. in addition I was trying to solve this by adding the export statement, but it didn't work. Notice: The code runs properly when it doesn't use mocha and as part of tests. The relevant code looks like this:

utils.js

exports.info = Logger.info;

let Logger {
info: function() {
   some code..
  }
}

test.js

Utils = require("../utils.js");
info = Utils.info;

describe('Tests', function(){
        it('', function(){
           call some functions which call to Logger.info()
        });
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