title: Mocha JS - mock parent class module
body: <h1>Background</h1>
  
  <p>I have class <code>A</code> that extends from class <code>B</code>:</p>
  
  <pre><code>A = class A
      ...
      my_inner_func: (param1) =&gt;
          return new MyHelper()
  
  B = class B extends A
      ...
  </code></pre>
  
  <h1>What I want to do?</h1>
  
  <p>In the unittest, <code>my_inner_func()</code> should return <code>MyMockHelper()</code>.</p>
  
  <h1>What I've tried</h1>
  
  <pre><code>a = rewire './a.coffee'
  b = rewire './b.coffee'
  
  a.__set__
      MyHelper: MyMockHelper
  
  b.__set__
      A: a.A
  </code></pre>
  
  <p>But <code>B().my_inner_func()</code> returns <code>MyHelper</code> instead of <code>MyMockHelper</code>.</p>
  
  <h1>My question</h1>
  
  <p>How does one mock a module used by an extended class in CoffeeScript (or JavaScript)?</p>