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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With