title: Delaying a response with $httpBackend
body: <p>In my view I have loading animation that is displayed until I receive a response from the API.</p>
  
  <pre><code>//Displayed before we've received API response
  &lt;p ng-if="vm.vehicles == null"&gt;Loading ...&lt;/p&gt;
  
  //Displayed once we received response for the API
  &lt;table ng-if="vm.vehicles"&gt;
      &lt;tr ng-repeat="vehicle.vm.vehicles"&gt;...&lt;/tr&gt;
  </code></pre>
  
  <p>To do my testing, I use the <code>$httpBackend</code> Angular module. Something like this:</p>
  
  <pre><code>$httpBackend.whenGET('api/vehicles').respond({vehicles: [...]});
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>I want to write a test to check the the loading animation is displayed.</p>
  
  <p>I tried:</p>
  
  <pre><code>expect(ptor.isElementPresent(By.cssContainingText('p', 'Loading'))).to.eventually.be.true;`
  </code></pre>
  
  <p>but i does't pass. So i think I need to conditionally delay the response I get from $httpBackend.</p>
  
  <p>I found this blog post <a href="http://endlessindirection.wordpress.com/2013/05/18/angularjs-delay-response-from-httpbackend/" rel="nofollow noreferrer">http://endlessindirection.wordpress.com/2013/05/18/angularjs-delay-response-from-httpbackend/</a></p>
  
  <p>However, inserting that config method made all my tests fails (I think because the templates aren't loaded in time), it delays ALL responses so it's not really what I need.</p>
  
  <p>So how can I delay the response for that one call? Ideally, I would like to delay it only for that test.</p>