Javascript 两套控制器测试套件,一套给出“;错误:[ng:areq]参数';modalController';不是函数,未定义;

Javascript 两套控制器测试套件,一套给出“;错误:[ng:areq]参数';modalController';不是函数,未定义;,javascript,angularjs,unit-testing,karma-jasmine,Javascript,Angularjs,Unit Testing,Karma Jasmine,控制器测试套件一(主控制器): 然后是另一个描述和its。这个很好用 第二个测试套件,用于我的模态控制器: describe("RTL cache viewing utility main controller test suite", function () { var $rootScope, mainCtrl; beforeEach(module('app')); beforeEach(inject(function ($controller, $rootScope, $compile

控制器测试套件一(主控制器):

然后是另一个描述和
it
s。这个很好用

第二个测试套件,用于我的模态控制器:

describe("RTL cache viewing utility main controller test suite", function () {

var $rootScope, mainCtrl;


beforeEach(module('app'));
beforeEach(inject(function ($controller, $rootScope, $compile, $q) {
    mainScope = $rootScope.$new();
    ctrl = $controller('mainCtrl', {
        $scope: mainScope
    });
}));
describe("RTL cache viewing utility modal controller test suite", function () {

var $rootScope, modalController;

beforeEach(module('app'));
beforeEach(inject(function ($controller, $rootScope, $compile) {
    mainScope = $rootScope.$new();
    ctrl = $controller('modalController', {
        $scope: mainScope
    });

}));
然后是另一个描述和一个
it

第二个控制器引发此错误:
error:[ng:areq]参数“modalController”不是函数,未定义

主控制器的声明:

var app = angular.module("app", ["agGrid", "ui.bootstrap"]);
angular.module("app").controller("mainCtrl", ["$scope", "$timeout", "dateFilter", "$http", "shareDataService", "getDataService", "$q", function ($scope, $timeout, dateFilter, $http, shareDataService, getDataService, $q) {

//stuff
}]);
模态控制器:

angular.module("app").controller("modalCtrl", ["$scope",     "shareDataService", "getDataService", function ($scope, shareDataService,     ngDialog, getDataService) {
//stuff
}]);

你似乎把名字弄混了


您的控制器声明为
modalCtrl
而不是您试图在测试中使用的
modalController
,您似乎混淆了名称


您的控制器声明为
modalCtrl
而不是您试图在测试中使用的
modalController
,谢谢!好长时间都在拔头发了,谢谢!多年来一直在拔头发。