title: Angular 2 Testing: What's the correct way for async testing?
body: <p>I have the following test in an angular 2 project with karma and jasmine:</p>
  
  <pre><code>let a: any;
  
  beforeEach(() =&gt; {
      a = {};
  
      setTimeout(() =&gt; {
          a.test();
      }, 1000);
  });
  
  it('should work with async and promise', async(() =&gt; {
  
     return new Promise((resolve) =&gt; {
         a.test = () =&gt; {
             console.log('erster test');
             assertThat(true, is(false));
             resolve();
         };
     });
  }));
  
  it('should work with async and done', async((done) =&gt; {
  
      a.test = () =&gt; {
          console.log('zweiter test');
          assertThat(true, is(false));
          done();
      };
  }));
  
  it('should work with done', (done) =&gt; {
  
      a.test = () =&gt; {
          console.log('dritter test');
          assertThat(true, is(false));
          done();
      };
  });
  </code></pre>
  
  <p>The only case that works (means it fails) is the last one with just a "done" callback. With the second one I'm not sure but shouldn't the first one be the correct way to test async in angular 2? I thought with "async" you place a zone around your function and it's waiting for the returned promise? I tried to make sense of the async implementation but I'm not getting it: <a href="https://github.com/angular/angular/blob/master/modules/%40angular/core/testing/async.ts" rel="nofollow">https://github.com/angular/angular/blob/master/modules/%40angular/core/testing/async.ts</a></p>