期望(服务).toBeDefined抛出Angular JS中的错误 - TypeError:' undefined'不是一个功能

时间:2015-01-14 22:53:05

标签: angularjs unit-testing mocha

我是Angular JS的新手,并尝试在mocha中为我的服务编写单元测试,但每次运行时都会低于错误。请建议。

TypeError: 'undefined' is not a function (evaluating 'expect(InfoService).toBeDefined()')

单元测试:

describe('Unit: InfoService', function () {

    var InfoService;
    var httpMock;

    beforeEach(angular.mock.module('app.Info'));
    beforeEach(angular.mock.module(function ($provide) {
        $provide.value('CONSTANT', {
        DETAIL_URL:'/test/someurl/'
    });          
}));

beforeEach(inject(function($httpBackend,InfoService) {
    InfoService = InfoService;
        httpMock = $httpBackend;
    }));

    it('InfoService should exist', function(InfoService){
        expect(InfoService).toBeDefined();
    });
});

0 个答案:

没有答案