title: How to test LoDash debounce in Jasmine with Sinon fakeTimer?
body: <p>I'm trying to write a test for debouncing user input in a search query. The function is defined on a Backbone View:</p>
  
  <pre><code>SearchView = Backbone.View.extend({
      events: {
          "input .search-input": "search"
      },
  
      // init, render, etc.
  
      search: _.debounce(function() {
          this.collection.fetch();   
      }, 200)
  });
  </code></pre>
  
  <p>Originally, the Backbone library (v0.9.10) used Underscore (v1.4.4), and the test was defined as follows:</p>
  
  <pre><code>describe("SearchView", function() {
      var view, $viewContainer;
  
      beforeEach(function() {
          appendSetFixtures('&lt;div class="jasmine-container"&gt;&lt;/div&gt;');
          $viewContainer = $(".jasmine-container");
  
          view = new SearchView({
              el: $viewContainer
          });
      });
  
      afterEach(function() {
          view.remove();
          view.cleanup();
      });
  
      //...
  
      describe("wires the search input", function() {
          var collectionStub,
              fakeTimer;
  
          beforeEach(function() {
              collectionStub = sinon.stub(
                  SearchResultsCollection.prototype,
                  "fetch"
              );     
  
              fakeTimer = sinon.useFakeTimers();
          });
  
          afterEach(function() { 
              collectionStub.restore();
              fakeTimer.restore();
          });
  
          it("should not trigger a search before 200ms", function() {
              fakeTimer.tick(199);
              expect(collectionStub).not.toHaveBeenCalled();
          });
  
          it("should trigger a search after 200ms", function() {
              fakeTimer.tick(200);
              expect(collectionStub).toHaveBeenCalled();
          });
      });
  });
  </code></pre>
  
  <p>However, now I want to incorporate LoDash instead of Underscore. Using the latest Underscore compatibility build on their site (LoDash 2.4.1 / Underscore 1.5.6), all my tests pass except for the one using _.debounce!</p>
  
  <p>I did some research and came across these <a href="https://github.com/lodash/lodash/issues/304">relevant</a> <a href="https://github.com/cjohansen/Sinon.JS/issues/343">issues</a> to create a LoDash Underscore build with runInContext, but I have no idea how to use it due to lack of examples. How can I use <code>_.runInContext()</code> in my spec(s) to work with <code>sinon.fakeTimer</code>?</p>