title: sinon stub on module function
body: <p>i'm trying test a es6 class, but i don't know how stub a function module whit sinon.
  The test not coverage line under sm.callSoap function</p>
  
  <p>I try this:</p>
  
  <p><strong>module.js</strong></p>
  
  <pre class="lang-js prettyprint-override"><code> function soapModule(){
        this.callSoap = (id) =&gt; {
           ....//some code
            return new Promise((resolve,reject) =&gt;{
               return resolve("whatever");
            }
        }
   }
  </code></pre>
  
  <p><strong>index.js</strong> (this is the index of the module)</p>
  
  <pre class="lang-js prettyprint-override"><code> "use strict";
  
   var soapModule = require('./module/module');
  
   module.exports.soapModule = soapModule;
  </code></pre>
  
  <p><strong>my-class.js</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>import {soapModule} from "soap-client"
  
  export default class MyClass {
  
     constructor(){
       console.log("instance created");
     }
  
     myMethod(id){
       let sm = new soapModule();
  
       return sm.callSoap(id)
              .then(result =&gt; {
                  console.log(result);
              }).catch(e =&gt; {
                  console.log("Error :" + e);
              })
     }
  }
  </code></pre>
  
  <p><strong>test.js</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>import MyClass from "../src/my-class";
  import {soapModule} from "soap-client";
  import sinon from 'sinon';
  
  describe("Test MyClass",()=&gt;{
  
      let myclass;
      let soap;
      let stub;
  
      before(()=&gt;{
          myclass = new MyClass();
          soap = new soapModule();
          stub = sinon.stub(soap,'callSoap');
      });
  
      it("test a", ()=&gt;{
          let fakeout = {
              resp : "tada!"
          }
          stub.resolves(fakeout);
          myclass.myMethod(1);
      });
  });
  </code></pre>
  
  <p>i try to stub on <strong>soapModule</strong> but generate this error: </p>
  
  <blockquote>
    <p>Cannot stub non-existent own property callSoap</p>
  </blockquote>