jeudi 19 novembre 2015

Angular JS: Error: [$injector:unpr] Unknown provider: $scopeProvider

I'm trying to write some unit tests for my app, but I'm running into an issue where I'm getting this error:

Chrome 46.0.2490 (Mac OS X 10.10.5) app.customer "before each" hook for "should be created successfully" FAILED Error: [$injector:unpr] Unknown provider: $scopeProvider <- $scope <- Customer

My test.js file looks like this:

describe('app.customers', function() {
  var controller;

  beforeEach(function() {
    module('app', function($provide) {});
    specHelper.injector(function($controller, $q, $rootScope, DataService) {});
  });

  beforeEach(function() {
    sinon.stub(DataService, 'getCustomers', function() {
      var deferred = $q.defer();
      deferred.resolve(mockData.getMockCustomers());
      return deferred.promise;
    });

    controller = $controller('Customer');
    $rootScope.$apply();
  });

  describe('Customer Controller', function() {
    it('should be created successfully', function() {
      expect(controller).to.be.defined;
    });
  });

  specHelper.verifyNoOutstandingHttpRequests();
});

I'm not sure why it's looking for $scopeProvider as I'm not referencing $scope.provider in my test.

I'm pretty new to unit testing in general, so any help with this would be appreciated. Thanks in advance!

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire