title: $provide is not a function when running a Karma test
body: <p>I would like to test an angular service. I get an error when executing the test with karma:</p>
  
  <pre><code>Error: [$injector:modulerr] Failed to instantiate module function ($provide) due to:
      TypeError: $provide is not a function
          at K:/home/projects/tmp/mobile/test/myservice.Spec.js:24:4
          at Object.invoke (K:/home/projects/tmp/mobile/vendor/angular/angular.js:4203:17)
          at K:/home/projects/tmp/mobile/vendor/angular/angular.js:4120:45
          at forEach (K:/home/projects/tmp/mobile/vendor/angular/angular.js:323:20)
          at loadModules (K:/home/projects/tmp/mobile/vendor/angular/angular.js:4099:5)
          at Object.createInjector [as injector] (K:/home/projects/tmp/mobile/vendor/angular/angular.js:4025:11)
          at Object.workFn (K:/home/projects/tmp/mobile/vendor/angular-mocks/angular-mocks.js:2425:52)
  
          at forEach (K:/home/projects/tmp/mobile/vendor/angular/angular.js:323:20)
          at loadModules (K:/home/projects/tmp/mobile/vendor/angular/angular.js:4099:5)
          at Object.createInjector [as injector] (K:/home/projects/tmp/mobile/vendor/angular/angular.js:4025:11)
          at Object.workFn (K:/home/projects/tmp/mobile/vendor/angular-mocks/angular-mocks.js:2425:52)
          at K:/home/projects/tmp/mobile/vendor/angular/angular.js:63:12
          at K:/home/projects/tmp/mobile/vendor/angular/angular.js:4138:15
      TypeError: Cannot read property 'getData' of undefined
          at Object.&lt;anonymous&gt; (K:/home/projects/tmp/mobile/test/myservice.Spec.js:38:11)
  </code></pre>
  
  <p>I want to test the <code>getData</code> from that service. The <code>getData</code> first check if data are in cache, if not it will call the server to retrieve the data. <code>Dashboards</code> is just a service created by Restangular.</p>
  
  <pre><code>var services = angular.module('services.dashboards', ['models.dashboards', 'models.metrics', 'LocalStorageModule', 'app.filters']);
  
  services.factory('DashboardsService', ['Restangular', '$q', 'Metrics', 'Dashboards', 'localStorageService', '$filter', 'filterByGradedFilter', function (Restangular, $q, Metrics, Dashboards, localStorageService, $filter, filterByGradedFilter) {
      var factory = {};
  
      factory.getData = function () {
          var defer = $q.defer();
          var data = localStorageService.get('data');
          if (data === undefined) {
              Dashboards.post()
                  .then(function (result) {
                      return Restangular.oneUrl('newDash', result.data).get();
                  })
                  .then(function (result) {
                      data = result.data;
                      localStorageService.set('data', data);
                      defer.resolve(data);
                  });
          } else {
              defer.resolve(data);
          }
          return defer.promise;
      }
  
      return factory;
  
  }]);
  </code></pre>
  
  <p>In the test, I mock <code>Restangular</code> and the <code>Dashboards</code> using <code>sinon</code>.</p>
  
  <pre><code>describe('Dashboards Service', function () {
  
      // Holds the service under test
      var service;
  
      beforeEach(module('services.dashboards'));
  
      // Mocks
      var mockRestangular;
      var mockDashboards;
      beforeEach(function () {
          mockRestangular = sinon.stub({
              oneUrl: function () {
  
              }
          });
          var expectedResponse = '{ dashid: xxxx}';
          mockDashboards = sinon.stub({
              post: function () {
                  return when(expectedResponse);
              }
          })
          module(function ($provide) {
              $provide('Restangular', mockRestangular);
              $provide('Dashboards', mockDashboards);
          })
  
      });
  
      // We inject the service
      beforeEach(inject(function (_DashboardsService_) {
          service = _DashboardsService_;
      }));
  
      describe('#getData', function () {
          it('should get a dashboard', function () {
              console.log(service);
              service.getData().then(function (result) {
                  console.log(result);
                  expect(result).toEqual({});
              })
          })
      })
  })
  </code></pre>