title: What is the difference between tick() and flush() in angular testing?
body: <p>On the angular documentation I see these two functions, <a href="https://angular.io/api/core/testing/tick" rel="noreferrer"><code>tick()</code></a> and <a href="https://angular.io/api/core/testing/flush" rel="noreferrer"><code>flush()</code></a>. Both of these seem to do similar things. From the angular documentation, it says for tick:</p>
  
  <blockquote>
    <p>Simulates the asynchronous passage of time for the timers in the fakeAsync zone.</p>
  </blockquote>
  
  <p>and for flush:</p>
  
  <blockquote>
    <p>Simulates the asynchronous passage of time for the timers in the fakeAsync zone by draining the macrotask queue until it is empty. The returned value is the milliseconds of time that would have been elapsed.</p>
  </blockquote>
  
  <p>Can anyone explain the difference to me?</p>
  
  <p>EDIT (answered in the comments):</p>
  
  <p>In addition, in the <a href="https://angular.io/guide/testing#component-with-async-service" rel="noreferrer">angular documentation</a> <code>tick()</code> is used without parameters, and the comment on that line even uses the phrase "flush"</p>
  
  <pre class="lang-js prettyprint-override"><code>it('should display error when TwainService fails', fakeAsync(() =&gt; {
    // tell spy to return an error observable
    getQuoteSpy.and.returnValue(
      throwError('TwainService test failure'));
  
    fixture.detectChanges(); // onInit()
    // sync spy errors immediately after init
  
    tick(); // flush the component's setTimeout()
  
    fixture.detectChanges(); // update errorMessage within setTimeout()
  
    expect(errorMessage()).toMatch(/test failure/, 'should display error');
    expect(quoteEl.textContent).toBe('...', 'should show placeholder');
  }));
  </code></pre>