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

162
Views
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
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!