title: How to change constant value in a Karma test
body: <p>I have an Angular directive which sets the value of some <code>$scope</code> property based on the value of an injected constant.  I want to test that this value is being correctly initialized from the constant, so I would like to change the constant's value within an individual <code>it</code> block. (Preferably within one, but changing the value between multiple blocks would be OK too)</p>
  
  <p>Is this possible, and how can I do it?</p>
  
  <p>simplified example:</p>
  
  <pre><code>//////// directive ////////
  angular.module('myApp.directives', [])
  .constant('THE_CONSTANT', 'hello world')
  .directive('myDirective', ['THE_CONSTANT', function (THE_CONSTANT) {
  
      return {
          restrict: 'E',
          link: function ($scope) {
              $scope.propertyBasedOnConstant = THE_CONSTANT;
          }
      };
  }]);
  
  //////// test ////////
  describe('myDirective', function () {
      var $element, $scope;
  
      beforeEach(module('myApp.directives'));
  
      beforeEach(module(function ($provide) {
          $provide.constant('THE_CONSTANT', 'foo');
      }));
  
      beforeEach(inject(function ($rootScope, $compile) {
          $scope = $rootScope;
          $element = angular.element('&lt;my-directive&gt;&lt;/my-directive&gt;');
          $compile($element)($scope);
          $scope.$digest();
      }));
  
      afterEach(function () {
          $scope.$destroy();
          $element.remove();
      });
  
      it("should correctly reflect the constant's value", function() {
          expect( $scope.propertyBasedOnConstant ).to.equal('foo');
  
          // now I want to change the constant's value and re-initialize the directive
      });    
  });
  </code></pre>