Skip to content

Uncaught ReferenceError: app is not defined and Error: [$injector:modulerr] Failed to instantiate module app due to: #147

@sangeetha1241

Description

@sangeetha1241

Error:

Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

karma.confi.js:

in files I added all reference files file to load module(app).

Spec.js

describe("create request test", function () {
var RequestService;
var inputRequest;
var RequestProvider;
var messageService;
var appConstants
var controller;
var scope;
var q;
var location;
var window;
var state;
var modal;
beforeEach(module("app"));

beforeEach(inject(function ($rootScope, $controller, $injector, $q,$location,$window,$state,$modal) {
		RequestService = $injector.get("RequestService");
  inputRequest = $injector.get("inputRequest");
  RequestProvider = $injector.get("RequestProvider");
  messageService = $injector.get("messageService");
  appConstants = $injector.get("appConstants");

		scope = $rootScope.$new;
		controller = $controller("createRequestController", {
				$scope : scope,
      $q:q,
      $location :location,
      $window :window,
      $state :state,
      $modal : modal
			});
	}));

it("controller should exist", function () {
	expect(controller).not.toBe(undefined);
});

it("controller call commentIndex method ", function () {
	
	expect(scope.commentIndex).toBeNull();
});

});

controller.js:

app.controller("createRequestController", [ '$scope', "$rootScope", "$q","$location", "$window", "$state","RequestService","inputRequest","RequestProvider","messageService","$modal","appConstants",
function($scope, $rootScope, $q, $location, $window, $state,RequestService,inputRequest,RequestProvider,messageService,$modal,appConstants) {
$scope.appConstants = appConstants;
$scope.commentIndex='';

app.js:

var app = MyApp = angular.module("MyApp", [ "ui.router", "ui.bootstrap",
"ngRoute" ,"agGrid","ui.select","ngTextTruncate","infinite-scroll","ngDragDrop","ngSanitize"]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions