title: mocha / sinon stub restore not working
body: <p>My first node test script. I'm using Mocha and Sinon to test a function which ultimately sends to a queue. Node v8.1.3, Mocha 5.0.2, sinon 4.4.2.</p>
  
  <pre><code>var assert = require('assert');
  var sinon = require('sinon');
  var uut = require('../util');
  var stub;
  
  describe('processWantedItemToQueue', function() {
      beforeEach(function() {
        stub = sinon.stub(uut, 'processWantedItemToQueue').returns(true);
      });
  
      afterEach(function() {
        uut.processWantedItemToQueue.restore();
      });
  
      it('should not push the item to the queue', function() {
        assert.equal(uut.processWantedItemToValidQueue("a", "q1"), false);
      });
  
      it('should push the item to the queue', function() {
        assert.equal(uut.processWantedItemToValidQueue("a", "aws"), true);
      });
  });
  </code></pre>
  
  <p>This is my output:</p>
  
  <pre><code>&gt; mocha
    processWantedItemToQueue
  ignoring queue q1
      ✓ should not push the item to the queue
      1) should push the item to the queue
  
  
    1 passing (34ms)
    1 failing
  
    1) processWantedItemToQueue
         should push the item to the queue:
       ReferenceError: processWantedItemToQueue is not defined
        at Object.processWantedItemToValidQueue (util.js:36:20)
        at Context.&lt;anonymous&gt; (test/test.js:20:24)
  </code></pre>
  
  <p>I've misunderstood something about stubs. Why isn't my second test finding the stub?</p>
  
  <p>My util.js looks like this:</p>
  
  <pre><code>module.exports = {
    processWantedItem: function(item) {
    ...
    },
    processWantedItemToQueue: function(item, queue) {
    ...
    },
    processWantedItemToValidQueue: function(item, queue) {
    ...
    }
  }
  </code></pre>