title: Qunit+SinonJs spy.calledOnce in setTimeout is undefined
body: <p>I have a problem understanding the behaviour of sinonjs spies. </p>
  
  <p>This is my test:</p>
  
  <pre><code>asyncTest('sinon async spies test', 
  function() { 
  
      var pApi = 
      { 
          product: function(id, options) { 
              var d = { o: 'a result' };
              options.success(d);
              return d;
          },
      };
  
      this.spy(pApi, 'product');
      pApi.product(1, { success: function(data) {} });
  
      //Assertion 1
      ok(pApi.product.calledOnce, 'product API called: ' + 
          pApi.product.calledOnce);
  
      setTimeout(
              function() { 
                  //Assertion 2
                  ok(pApi.product.calledOnce, 
                      'product function called once (calledOnce: ' +   
                       pApi.product.calledOnce + ')');
                  start();
              }, 1000);
  
  });
  </code></pre>
  
  <p>Running the above test with qunit and sinonjs (via sinon-qunit), I pass Assertion 1 but fail the Assertion 2 (within the setTimeout callback). In fact, when we log the value of <code>pApi.product.calledOnce</code> in the console (as is done via the assertion's message), it is <code>undefined</code>. </p>
  
  <p>Note: I have this at the top of my test file: </p>
  
  <pre><code>sinon.config.useFakeTimers = false;
  </code></pre>
  
  <p>Could anyone explain this curious behaviour? Shouldn't <code>pApi.product</code> within the setTimeout callback and without both have <code>calledOnce</code> as a valid property of the spy?</p>
  
  <p><strong>Updated</strong></p>
  
  <p>Based on <a href="http://api.qunitjs.com/asyncTest/" rel="nofollow">http://api.qunitjs.com/asyncTest/</a>, I figured out why the above behaviour is displayed.</p>
  
  <p><code>asyncTest</code> does not run the testrunner until the <code>start()</code> function is called. The above test worked when I changed <code>this.spy(pApi, 'product')</code> to <code>sinon.spy(pApi, 'product')</code>. Apparently there is a dependency on whether <code>test</code> is used instead of <code>asyncTest</code>, which affects when the <code>this.spy</code> method is run.</p>
  
  <p>Will need to actually look at the sinon, qunit and sinon-qunit code in order to figure this one out. </p>