notAChance
notAChance

Reputation: 1430

Two controller test suites, one giving " Error: [ng:areq] Argument 'modalController' is not a function, got undefined"

Controller test suite one (main controller):

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
    });
}));

followed by another describe and its. This one works fine.

Second test suite, for my modal controller:

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
    });

}));

followed by another describe and one it.

Second controller throws this error: Error: [ng:areq] Argument 'modalController' is not a function, got undefined

Declarations for main controller :

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
}]);

modal controller :

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

Upvotes: 0

Views: 39

Answers (1)

charlietfl
charlietfl

Reputation: 171679

You seem to have the names mixed up

Your controller is declared as modalCtrl not modalController that you are trying to use in test

Upvotes: 2

Related Questions