title: angularjs: how to mock $rootScope in unit test
body: <p>I have a unit test that looks like this</p>
  
  <pre><code>describe('Interceptor: myInterceptor', inject(function($rootScope){
      var rootScope, routeParams = { id: null };
  
      beforeEach(module('MyApp', function ($provide) {
          $provide.factory('$routeParams', function () {   // mock $routeParams
              return routeParams;
          });
  
          rootScope = $rootScope.$new();
          $provide.value('$rootScope', rootScope);         // mock $rootScope
  
      }));
      ....
  }));
  </code></pre>
  
  <p>However when I do "inject(function($rootScope){ .." as I have shown above, I get the following error (using Karma and PhantomJS):</p>
  
  <pre><code>PhantomJS 1.9.2 (Mac OS X) Interceptor: myInterceptor encountered a declaration exception FAILED
  TypeError: 'null' is not an object (evaluating 'currentSpec.$modules')
      at workFn (/dev/myapp/app/bower_components/angular-mocks/angular-mocks.js:2072)
      at /dev/myapp/test/spec/interceptors/my-interceptor.js:67
      ....
  </code></pre>