简体   繁体   中英

module not found when setting angular controller test

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM