Reputation: 2639
I try to set up angular controller unit test following this guide, the code is as follows:
describe('ProfileController', function() {
// load haloApp module
beforeEach(module('haloApp'));
it("should have notify_changed in scope", inject(function($controller) {
var scope= {},
ctrl = $controller('ProfileController', {$scope:scope});// inject controller
// expect(ProfileController).not.toBeDefined();
expect(scope.notify_changed).toBe(false);
}));
});
When I run this test case with jasmine, it report the following error:
ReferenceError: module is not defined
I have required angular file before this code snippet. Is there anything I am missing?
Upvotes: 0
Views: 144
Reputation: 40337
The module
function is a part of the ngMock
module defined in angular-mocks.js. Make sure that file is included when running your tests. See https://docs.angularjs.org/api/ngMock and https://docs.angularjs.org/api/ngMock/function/angular.mock.module
Upvotes: 0