8
I am trying to do some basic Unit testing for AngularJS using Karma. All the tests I have written seem syntactically correct. But I am having a problem at the most basic step, i.e the beforeEach part of the code. When I try running the test, I get the following problem
TypeError: Cannot read property '$injector' of null
at Object.workFn (http://localhost:9876/absolute/Users/vesriram/Documents/AngularJS%20project/vendor/js/angular-mocks.js:1698:15)
at Object.<anonymous> (http://localhost:9876/adapter/lib/angular-scenario.js:26360:54)
at Array.forEach (native)
at Object.forEach (http://localhost:9876/adapter/lib/angular-scenario.js:9593:11)
I have been trying to solve this problem for the past 36 hours and have had no luck so far. As far as I can see, noone else seems to be having this problem. This makes me think that I am possibly doing something stupid. I would really appreciate any help you people could give me. I will be happy to post any additional code that you need (so long as I am at liberty to divulge it).
The relevant code is the following-
app.js
var sell_page = angular.module("sell_page", ['ui.bootstrap']);
sell_page.controller('ItemTitleController', ['$scope','listingInformationService', '$location',function($scope, listingInformationService, $location) {
$scope.itemNames = getAllItemNames();
$scope.draftItems = getAllSavedDrafts();
document.getElementById("categorySelection").style.visibility = "hidden";
------bunch of code-------
}]);
controllersSpec.js
describe("Unit: Testing Controllers", function() {
beforeEach(angular.mock.module('sell_page'));
it('should have a ItemTitleController controller', function() {
expect(sell_page.ItemTitleController).not.to.equal(null);
});
describe("ItemTitleController", function() {
var scope;
beforeEach(angular.mock.module('sell_page'));