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()
});