Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda