0
カルマとジャスミンフレームワークを使用してnode.jsアプリケーションをテストしようとしています。私が直面している問題は、コントローラの名前が登録されていないというエラーです。スコープ変数がnullであるかどうかを調べるための簡単なテストを試みています。カルマでJavascriptコントローラが見つかりません
エラー:「scheduleCtrl」という名前のコントローラが登録されていません。
私はここ リンクチュートリアルを次されています:https://docs.angularjs.org/guide/controller
scheduleController.js
angular.module('myApp').controller('scheduleCtrl',
['$scope', '$http', function($scope, $http){
var indexOfHtml = window.
$scope.selectedPatient = null;
}
scheduleController_spec.js
describe("schedule Controller",function(){
beforeEach(angular.module('myApp'));
var $controller;
var $scope = {};
beforeEach(inject(function($rootScope, $controller){
$scope = $rootScope.$new();
//this creates a controller for us to use
$controller('scheduleCtrl', { $scope: $scope});
}));
it(" should expect null ", function(){
expect($scope.selectedPatient).toEqual(null);
});
//});
を});
カルマ-config.jsの
files: [
'./node_modules/angular/angular.js',
'./node_modules/angular-ui-router/release/angular-ui-router.js',
'./node_modules/angular-mocks/angular-mocks.js',
'./web/static/scripts/app.js',
'./web/static/views/home.html',
'./web/static/scripts/homeController.js',
'./web/static/scripts/scheduleController.js',
'./spec/spec_test.js'
],
エラー出力
Chrome 56.0.2924 (Mac OS X 10.11.2) schedule Controller should expect null FAILED
TypeError: queueableFn.fn.call is not a function
Error: [$controller:ctrlreg] The controller with the name 'scheduleCtrl' is not registered.
http://errors.angularjs.org/1.6.2/$controller/ctrlreg?p0=scheduleCtrl
at node_modules/angular/angular.js:68:12
at $controller (node_modules/angular/angular.js:10690:17)
at node_modules/angular-mocks/angular-mocks.js:2296:14
at Object.<anonymous> (spec/scheduleController_spec.js:18:3)
at Object.invoke (node_modules/angular/angular.js:4862:19)
at Object.WorkFn (node_modules/angular-mocks/angular-mocks.js:3170:20)
Error: Declaration Location
at window.inject.angular.mock.inject (node_modules/angular-mocks/angular-mocks.js:3133:25)
at Suite.<anonymous> (spec/scheduleController_spec.js:15:13)
at spec/scheduleController_spec.js:4:1
Expected undefined to equal null.
at Object.<anonymous> (spec/scheduleController_spec.js:26:35)
クローム56.0.2924する(Mac OS X 10.11.2):1の実行される1(1 FAILED)ERROR(0.046秒/ 0.033 secs)