title: Testing angularjs directive with dependencies
body: <p>I'm new to AngularJs and having problem trying to test a directive with dependency (although the directive itself works as expected). I was unable to find any answers here or on the other resources. </p>
  
  <p>Here is my code:</p>
  
  <p>Directive:</p>
  
  <pre class="lang-js prettyprint-override"><code>angular.module('MyApp')
    .directive('appVersion', ['config', function (config) {
      return function (scope, elm) {
        elm.text(config.version);
      };
    }]);
  </code></pre>
  
  <p>Service (value):</p>
  
  <pre class="lang-js prettyprint-override"><code>angular.module('MyApp')
    .value('config', {
      version: '0.1'
    });
  </code></pre>
  
  <p>Test:</p>
  
  <pre class="lang-js prettyprint-override"><code>describe('Directive: AppVersion', function () {
      beforeEach(module('MyApp'));
  
      var element;
  
      it('should have element text set to config value', inject(function ($rootScope, $compile, config) {
          var scope = $rootScope;
          element = $compile('&lt;app-version&gt;&lt;/app-version&gt;')(scope);
          expect(element.text()).toBe(config.version);
      }));
  });
  </code></pre>
  
  <p>My test is failing with message:</p>
  
  <pre><code>Error: Expected '' to be '0.1'.
  </code></pre>
  
  <p>meaning that config value got injected properly, but $complile was not using it. I would really appreciate any help on this. Thanks.</p>