Reputation: 407
I have the following NewPageCtrl.js
angular.module('NewPageCtrl', []).controller('NewPageController', function($scope, $document) {
$scope.showMe = false;
});
And the following test.js
describe('NewPageCtrl', function() {
var scope, $document, createController;
beforeEach(inject(function ($rootScope, $controller _$document_) {
$document = _$document_;
scope = $rootScope.$new();
createController = function() {
return $controller('NewPageCtrl', {
'$scope': scope
});
};
}));
it('should check showMe', function() {
});
});
I will write the test case later, but for now Jasmine is giving me the error:
Chrome 48.0.2564 (Mac OS X 10.10.5) ERROR
Uncaught SyntaxError: Unexpected identifier
at /Users/me/myProject/test/test.js:23
Line 23 is the beforeEach(... line
I got the example from http://nathanleclaire.com/blog/2013/12/13/how-to-unit-test-controllers-in-angularjs-without-setting-your-hair-on-fire/
Upvotes: 0
Views: 73
Reputation: 2847
You missed a comma.
Change
$rootScope, $controller _$document_
to
$rootScope, $controller, _$document_
Upvotes: 1