title: How to properly mock ES6 classes with sinon
body: <p>I want to be able to properly test my ES6 class, it's constructor requires another class and all this looks like this:</p>
  
  <p><strong>Class A</strong></p>
  
  <pre><code>class A {
    constructor(b) {
      this.b = b;
    }
  
    doSomething(id) {
      return new Promise( (resolve, reject) =&gt; {
        this.b.doOther()
          .then( () =&gt; {
            // various things that will resolve or reject
          });
      });
    }
  }
  module.exports = A;
  </code></pre>
  
  <p><strong>Class B</strong></p>
  
  <pre><code>class B {
    constructor() {}
  
    doOther() {
      return new Promise( (resolve, reject) =&gt; {
        // various things that will resolve or reject
      });
  }
  module.exports = new B();
  </code></pre>
  
  <p><strong>index</strong></p>
  
  <pre><code>const A = require('A');
  const b = require('b');
  
  const a = new A(b);
  a.doSomething(123)
    .then(() =&gt; {
      // things
    });
  </code></pre>
  
  <p>Since I'm trying to do dependency injection rather than having requires at the top of the classes, I'm not sure how to go about mocking class B and it's functions for testing class A.</p>