title: NodeJS: Unit Test for class calling constructor and functions of another class
body: <p>I need to write an unit test for the following classA. I do not want to test methodA but set a dummy method instead:</p>
  <pre><code>const classB = require('classB');
  function a() {
    const b = classB();
    b.methodA();
  }
  </code></pre>
  <p>I tried to use rewire:</p>
  <pre><code>const classA = rewire('classA');
  const classBMock = require('classB');
  classBMock.prototype.methodA = function() {
  }
  classA.__set__('classB', classBMock);
  classA.a();
  </code></pre>
  <p>Is there a better way to achieve my goal?</p>
  <p>Thanks!</p>