Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown provider: $rootscopeProvider <- $rootscope

Tags:

I'm trying to inject $scope into a jasmine test, but get the exception

Unknown provider: $rootscopeProvider <- $rootscope 

My Spec file is this:

describe("with data returned from NormDefinitions API", function () {     const dummyData = [         {"Id": 1, "Name": "Name 1", "Description": "Description 1"},         {"Id": 2, "Name": "Name 2", "Description": "Description 1"}     ];      var $scope,         mockService = {             query: function () {                 return  dummyData;             }         };      beforeEach(inject(function ($rootscope) {          $scope = $rootscope.$new();     }));      it("it can be instantiated", inject(function($controller) {         var controller = $controller("NormDefinitionsController",             {                 $scope: $scope,                 myService : mockService             });          expect(controller).not.toBeNull();     })); }); 

What am I missing?

THanks

Dave

like image 228
BanksySan Avatar asked Mar 29 '13 17:03

BanksySan


1 Answers

Typo (happens to all of us): $rootScope with a capital S.

Sometimes people forget to inject it. Then you'd get this error:

ReferenceError: $rootScope is not defined 
like image 160
Mark Rajcok Avatar answered Oct 30 '22 20:10

Mark Rajcok