title: Sinon stub has weird behavior when used with mocha watch
body: <p>So here's the basic setup we have</p>
  
  <p><code>src/MyComponent.js</code></p>
  
  <pre><code>import actions from `src/actions`
  
   export const mapDispatchToProps = dispatch =&gt; {
      return {
        onClick: () =&gt; {
          dispatch(actions.myAction())
        }
      }
   }
  </code></pre>
  
  <p><code>src/actions.js</code></p>
  
  <pre><code>const actions = { 
    myAction: () =&gt; () =&gt; ...
  }
  export default actions
  </code></pre>
  
  <p><code>src/MyComponentTest.js</code></p>
  
  <pre><code> import sinon from 'sinon'
   import actions from 'src/actions'
   import { mapDispatchToProps } from 'src/MyComponent'
  
   describe('onClickTests, () =&gt; {
     let dispatch = sinon.spy()
     let onClick
  
     beforeEach(() =&gt; {
       onClick = mapDispatchToProps(dispatch).onClick
     })
  
     it('calls dispatch with myAction', () =&gt; {
       function f () {}
       sinon.stub(actions, 'myAction').returns(f)
       onClick()
       expect(dispatch.args[0]).to.deep.equal([f])
     })
   })
  </code></pre>
  
  <p>Basically, we're checking that the <code>onClick</code> function is calling <code>dispatch</code> with the return value of <code>actions.myAction</code>. Since the real <code>actions.myAction</code> returns an anonymous function, we're stubbing it to return the function <code>f</code>. When we run this with Mocha everything works, until we run with <code>--watch</code>. The first run still passes as expected, but when we save a test and the tests are re-run, this tests fails with</p>
  
  <pre><code>expected [ [Function: f] ] to deeply equal [ [Function: f] ]
  </code></pre>
  
  <p>If I made these changes to the test</p>
  
  <pre><code>   it('calls dispatch with myAction', () =&gt; {
       function f () {}
       sinon.stub(actions, 'myAction').returns(2)
       onClick()
       expect(dispatch.args[0]).to.deep.equal([2])
     })
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>expected [ [Function: f] ] to deeply equal [ [2] ]
  </code></pre>
  
  <p>So what I gather from this is that on the second run, the <code>f</code> that <code>actions.minimize</code> returned was the "old" <code>f</code> from the first run. We've tried a wide variety of different variations on this like using <code>module.exports/require</code> instead of <code>export/import</code> and moving things around into Mocha hooks (<code>beforeEach</code>, etc) and nothing seems to be working, which leads me to believe this is a more fundamental issue with how we're testing. Any suggestions?</p>