title: Use angularjs directive templates from $templateCache in karma tests
body: <p>I know how to <a href="https://github.com/vojtajina/ng-directive-testing" rel="nofollow">load templates in my karma tests using the ng-html2js preprocessor</a>. However, in our project we have a <em>templates.js</em> file already that looks like so:</p>
  
  <pre><code>angular.module("myApp").run(
      ["$templateCache", function($templateCache) {
          $templateCache.put(
              "app/directive-template.html",
              "&lt;span&gt;Some fancy template.&lt;/span&gt;");
      ...
  });
  </code></pre>
  
  <p>It is generated with the <a href="https://github.com/miickel/gulp-angular-templatecache" rel="nofollow">gulp-angular-templatecache</a> plugin. This works great for production but fails for tests. The file is included in the <em>karma.conf.js</em> and loads correctly, but the run-function is only executed <strong>after</strong> the tests have executed.</p>
  
  <p>How can I make karma wait for the run phase so the templates are loaded before the tests are executed?</p>