[英]Testing AngularJS controller with Jasmine
我有以下NewPageCtrl.js
angular.module('NewPageCtrl', []).controller('NewPageController', function($scope, $document) {
$scope.showMe = false;
});
和下面的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() {
});
});
稍后我將編寫測試用例,但是現在Jasmine給了我錯誤:
Chrome 48.0.2564 (Mac OS X 10.10.5) ERROR
Uncaught SyntaxError: Unexpected identifier
at /Users/me/myProject/test/test.js:23
第23行是beforeEach(...
您錯過了一個逗號。
更改
$rootScope, $controller _$document_
至
$rootScope, $controller, _$document_
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.