title: Javascript Mocha test TypeError: x is not a constructor
body: <p>I'm using two js files to make a test with Mocha.</p>
  
  <p>My <strong>test.js</strong> file looks like this:</p>
  
  <pre><code>const assert = require('assert');
  const operations = require('./operations.js');
  
  it('Calculates correct deserialization', () =&gt; {
  
    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');
  });
  </code></pre>
  
  <p>and my <strong>operations.js</strong> file looks like this:</p>
  
  <pre><code>function Node(val, left, right) {
    this.val = val;
    this.left = left;
    this.right = right;
  }
  </code></pre>
  
  <p>although incomplete, the test fails to instantiate the Node objects, and
  exits with the message </p>
  
  <blockquote>
    <p>"TypeError: operations.Node is not a constructor"</p>
  </blockquote>
  
  <p>I've already tried with </p>
  
  <pre><code>var leftLeft = new Node('left.left', null, null);
  </code></pre>
  
  <p>that is, without de <code>operations.Node()</code>.
  I'm using strict mode.</p>