title: How jasmine works with Async Test
body: <p>All:</p>
  
  <p>I am pretty new to Jasmine testing, one question I am wondering about async test is:</p>
  
  <p>Could anybody give a brief explanation how does Jasmine know there is a done() function call inside and waiting for that finish? </p>
  
  <p>For example, if I put some async call in beforeEach:</p>
  
  <pre><code>var flag = false;
  beforeEach(function(done){
      setTimeout(function(){
          // some task here
          flag = true;
          done();
      }, 3000)
  })
  
  it("Should be true if the async call has completed", function () {
      expect(flag).toEqual(true);
  });
  </code></pre>
  
  <p>How Jasmine know it should let that <code>it</code> spec test wait?  </p>
  
  <p>Thanks </p>