I'm using two js files to make a test with Mocha.
My test.js file looks like this:
const assert = require('assert');
const operations = require('./operations.js');
it('Calculates correct deserialization', () => {
var leftLeft = new operations.Node('left.left', null, null);
var left = new operations.Node('left', leftLeft, null);
var right = new operations.Node('right', null, null);
var root = new operations.Node('root', left, right);
assert.equal(operations.deserialize(serialize(root)).left.left.val == 'left.left');
});
and my operations.js file looks like this:
function Node(val, left, right) {
this.val = val;
this.left = left;
this.right = right;
}
although incomplete, the test fails to instantiate the Node objects, and exits with the message
"TypeError: operations.Node is not a constructor"
I've already tried with
var leftLeft = new Node('left.left', null, null);
that is, without de operations.Node().
I'm using strict mode.