title: Angular with Jasmine error: Controller required by directive can't be found
body: <p>I have an application which has two directives, where one directive requires the other. I have replicated it to mirror the base of the application:</p>
  
  <pre><code>var module = angular.module('testApp', ['testApp.directiveA', 'testApp.directiveB']);
  
  // Here goes your modules definition
  module.controller('AppCtrl', function ($scope, $log) {
  });
  
  angular.module('testApp.directiveA', ['testApp.directiveB'])
  
  .directive('directiveA', function () {
      return {
          restrict: 'EA',
      require: '^directiveB',
          template: '&lt;div&gt;&lt;h1&gt;DirectiveA&lt;/h1&gt;&lt;/div&gt;',
      scope: {
        value: "@"
      },
          link: function (scope, element, attrs, directiveBCtrl) {
              scope.testFunction = function() {
                  return directiveBCtrl.exampleFunction();
              };
  
              scope.value = scope.testFunction();
          }
      }
  });
  
  angular.module('testApp.directiveB', [])
  
  .directive('directiveB', function () {
      return {
          restrict: 'EA',
          template: '&lt;div&gt;&lt;h1&gt;DirectiveB&lt;/h1&gt;&lt;/div&gt;',
      scope: {
        value: "@"
      },
          controller: function ($scope) {
              $scope.exampleFunction = function() {
                  return true;
              };
          }
      }
  });
  </code></pre>
  
  <p>I am trying to write a test using Jasmine to test different functions in directiveA:</p>
  
  <pre><code>describe('Test directive with require', function () {
  
      var $scope, elem, scope;
  
      beforeEach(angular.mock.module("testApp.directiveA", "testApp.directiveB"));
  
      beforeEach(inject(function ($rootScope, $compile) {
  
          elem = angular.element('&lt;directive-a value="aValue"&gt;&lt;/directive-a&gt;');
  
          $scope = $rootScope.$new();
  
          $compile(elem)($scope);
  
          $scope.$digest();
  
          scope = elem.isolateScope();
  
      }));
  
      it('Should test a function on directiveA', function() {
  
          var result = scope.testFunction();
          expect(result).toEqual(true);
      });
  });
  </code></pre>
  
  <p>When I run this, I get the error:</p>
  
  <pre><code>Controller 'directiveB', required by directive 'directiveA', can't be found!
  </code></pre>
  
  <p>I have setup A Plnkr which reproduces the error. I cannot seem to figure out how I can inject one directive, or rather its controller, into the other directive. Any help is greatly appreciate.</p>
  
  <p><a href="http://plnkr.co/edit/pKDNkiO1ZHxE6qQKXXF5?p=preview" rel="nofollow">http://plnkr.co/edit/pKDNkiO1ZHxE6qQKXXF5?p=preview</a></p>