I am trying to test my AngularJS controller using Jasmine with Karma. When I try the documented procedure for configuring a controller test, the $scope is not being created. Actually it looks like the before is not executing at all.
Here is my controller declaration:
angular.module("myApp", ["ngCookies"])
.controller("myCtrl", function($scope, $window, $location, MyService,
$timeout, $log, $cookies, $q) {
My test looks like this:
describe("MyController test", function() {
var $scope;
beforeEach(
module("myApp", ["ngCookies"]));
beforeEach(inject(function($rootScope, $controller) {
$scope = $rootScope.$new(); // It looks like this is never called
scope =$scope;
$controller("myCtrl", {$scope: $scope});
}));
it("Checks the state of various units", function() {
...
});
It looks like the beforeEach stuff is never called. I presume I need to inject the rest of my properties into the controller, but if so, I am not sure how.
This is the error in the Test Run log
FAILED MyController test Checks myFunction starting from blank state
Error: [$injector:modulerr] Failed to instantiate module ngCookies due to:
Error: [ng:areq] Argument 'fn' is not a function, got string
http://errors.angularjs.org/1.3.14/ng/areqp0=fn&p1=not%20a%20function%2C%20got%20string