我正在用茉莉花测试角度应用。在测试文件中,我已经注入了谷歌地图模块:
beforeEach(module('uiGmapgoogle-maps'));
uiGmapgoogle-maps 也会添加为我的应用程序的app模块的依赖项。
在karma.conf.js文件的文件数组中,我添加了
'app/lib/angular-google-maps/dist/angular-google-maps.js',
我正在尝试测试服务存在,其中 uiGmapGoogleMapApi 是该服务的依赖项。
我正在使用此代码测试此服务(geoLocationService)。
beforeEach(inject(function(_geoLocationService_) {
geoLocationFactory = _geoLocationService_;
}));
it('geoLocationFactory should be defined.', function () {
expect(geoLocationFactory).toBeDefined();
});
在 expect(geoLocationFactory).toBeDefined(); 上,它给出了如下错误:
Error: [$injector:modulerr] Failed to instantiate module uiGmapgoogle-maps due to:
Error: [$injector:nomod] Module 'uiGmapgoogle-maps' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dep
endencies as the second argument.