title: Why is using jasmine's runs and waitFor function necessary?
body: <p>I'm testing an asynchronous piece of code with something that looks like this:</p>
  
  <pre><code>randomService.doSomething().then(function() {
      console.log('I completed the operation!');
  });
  </code></pre>
  
  <p>Surprisingly (to me) I've found that it only succeeds (ie console.log output is shown) when wrapped inside jasmine's <code>runs</code> function, like so:</p>
  
  <pre><code>var isDone = false;
  
  runs(function() {
      randomService.doSomething().then(function(data) {
          console.log('I completed the operation!');
          isDone = true;
      });
  });
  
  waitsFor(function() {
      return isDone;
  }, 'Operation should be completed', 1000);
  </code></pre>
  
  <p>As I understood it, I thought <code>waitsFor</code> was only to delay the code, in other words I would use it if I had more code that I had to delay until after the asynchronous call completed - in other words, I would have thought that there'd be no reason for me to use <code>runs</code> and <code>waitsFor</code> since there's nothing that comes after this bit of code, right? That's the impression I got from reading this question: <a href="https://stackoverflow.com/questions/16400047/what-do-jasmine-runs-and-waitsfor-actually-do">What do jasmine runs and waitsFor actually do?</a> but obviously I've gotten myself mixed up at some point. </p>
  
  <p>Does anyone have any thoughts on this?</p>
  
  <hr>
  
  <p><strong>EDIT:</strong>
  Here is a Plunker with far more detail of the problem:
  <a href="http://plnkr.co/edit/3qnuj5N9Thb2UdgoxYaD?p=preview" rel="nofollow">http://plnkr.co/edit/3qnuj5N9Thb2UdgoxYaD?p=preview</a></p>
  
  <p>Note how the first test always passes, and the second test fails as it should. 
  Also, I'm sure I should have mentioned this before, but this is using angularJS, and Jasmine 1.3.</p>