该应用程序运行良好,但当我运行Karma对控制器进行单元测试时......
这是错误:
Error: [$injector:unpr] Unknown provider: NgMapProvider <- NgMap
http://errors.angularjs.org/1.4.10/$injector/unpr?p0=NgMapProvider%20%3C-%20NgMap
这是我的测试:
describe('dashBoardEmployeeCtrl', function(){
var ctrl, scope, $httpBackend
var data = [{longitude: 1, latitude: 2, description: "cool office", name: "new your office"}]
beforeEach(function(){
module('dashBoardApp.employeeLocations');
inject(function($controller, $rootScope, _$httpBackend_, NgMap){
$httpBackend = _$httpBackend_;
$httpBackend.expectGET('http://localhost:3000/something.json').respond(data)
scope = $rootScope.$new();
ctrl = $controller('dashBoardEmployeeCtrl', {$scope:scope})
});
});
it('has a attribute called $scope.employeeLocations that returns an object from api', function(){
$httpBackend.flush()
expect(scope.Locations).toEqual([{longitude: 1, latitude: 2, description: "cool office", name: "new your office"}])
})
});
这是我的Karma.config.js
files : [
'http://maps.google.com/maps/api/js',
'app/bower_components/angular/angular.js',
'app/bower_components/ngmap/build/scripts/*.js',
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/angular-mocks/angular-mocks.js',
'app/components/**/*.js',
'app/dashBoard/*.js',
'app/services/*.js',
'app/bower_components/ngmap/build/scripts/ng-map.min.js',
'app/dashBoard/*.html',
'unit-tests/*.js',
],