title: Unit Testing AngularJS directive with templateUrl
body: <p>Using AngularJS.</p>
  <p>Have a directive.</p>
  <p>Directive defines <code>templateUrl</code>.</p>
  <p>Directive needs unit testing.</p>
  <p>Currently unit testing with Jasmine.</p>
  <p><a href="https://stackoverflow.com/questions/14761045/jasmine-tests-angularjs-directives-with-templateurl">This</a> recommends code like:</p>
  <pre><code>describe('module: my.module', function () {
      beforeEach(module('my.module'));
  
      describe('my-directive directive', function () {
          var scope, $compile;
          beforeEach(inject(function (_$rootScope_, _$compile_, $injector) {
              scope = _$rootScope_;
              $compile = _$compile_;
              $httpBackend = $injector.get('$httpBackend');
              $httpBackend.whenGET('path/to/template.html').passThrough();
          }));
  
          describe('test', function () {
              var element;
              beforeEach(function () {
                  element = $compile(
                      '&lt;my-directive&gt;&lt;/my-directive&gt;')(scope);
                  angular.element(document.body).append(element);
              });
  
              afterEach(function () {
                  element.remove();
              });
  
              it('test', function () {
                  expect(element.html()).toBe('asdf');
              });
  
          });
      });
  });
  </code></pre>
  <p>Running code in Jasmine.</p>
  <p>Getting error:</p>
  <pre><code>TypeError: Object #&lt;Object&gt; has no method 'passThrough'
  </code></pre>
  <p>templateUrl needs loading as-is</p>
  <p>Cannot use <code>respond</code></p>
  <p>May be related to <a href="http://docs.angularjs.org/api/ngMock.$httpBackend" rel="nofollow noreferrer">ngMock</a> use rather than <a href="http://docs.angularjs.org/api/ngMockE2E.$httpBackend" rel="nofollow noreferrer">ngMockE2E</a> use.</p>