0

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/

3
  • Change $rootScope, $controller _$document_ to $rootScope, $controller, _$document_, comma missing! Commented Feb 18, 2016 at 15:30
  • Funny it's also on the page :) Commented Feb 18, 2016 at 15:31
  • Fantastic! Well spotted. Post an answer and ill mark it. Commented Feb 22, 2016 at 6:16

1 Answer 1

1

You missed a comma.

Change

$rootScope, $controller _$document_

to

$rootScope, $controller, _$document_
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.