title: Testing directives that require controllers
body: <p>So I did see another question: <a href="https://stackoverflow.com/questions/16514045/how-to-mock-required-directive-controller-in-directive-ut">How to mock required directive controller in directive UT</a> which is basically my problem but it seems the answer to this thread was "change your design." I wanted to make sure there is no way to do this. I have a directive that declares a controller which is used by children directives. I am now trying to write jasmine tests for the children directive but I cant get them to compile in the tests because they are dependent on the controller. Here is what it looks like:</p>
  
  <pre><code>addressModule.directive('address', ['$http', function($http){
          return {
              replace: false,
              restrict: 'A',
              scope: {
                  config: '='
              },
              template:   '&lt;div id="addressContainer"&gt;' +
                              '&lt;div ng-if="!showAddressSelectionPage" basic-address config="config"/&gt;' +
                              '&lt;div ng-if="showAddressSelectionPage" address-selector addresses="standardizedAddresses"/&gt;' +
                          '&lt;/div&gt;',
              controller: function($scope)
              {
                  this.showAddressInput = function(){
                      $scope.showAddressSelectionPage = false;
                  };
  
                  this.showAddressSelection = function(){
                      $scope.getStandardizedAddresses();
                  };
  
                  this.finish = function(){
                      $scope.finishAddress();
                  };
              },
              link: function(scope, element, attrs) {
                ...
              }
         }
  }])
  </code></pre>
  
  <p>child directive:</p>
  
  <pre><code>addressModule.directive('basicAddress360', ['translationService', function(translationService){
          return {
              replace: true,
              restrict: 'A',
              scope: {
                  config: '='
              },
              template:
                  '...',
              require: "^address360",
              link: function(scope, element, attrs, addressController){
              ...
              }
         }
  }])
  </code></pre>
  
  <p>jasmine test:</p>
  
  <pre><code>it("should do something", inject(function($compile, $rootScope){
              parentHtml = '&lt;div address/&gt;';
              subDirectiveHtml = '&lt;div basic-address&gt;';
  
              parentElement = $compile(parentHtml)(rootScope);
              parentScope = parentElement.scope();
              directiveElement = $compile(subDirectiveHtml)(parentScope);
              directiveScope = directiveElement.scope();
              $rootScope.$digest();
  }));
  </code></pre>
  
  <p>Is there no way for me to test the sub directive with jasmine and if so, what am I missing? Even if I could test the directive itself without the controller functions I would be happy.</p>