2016-07-07 50 views
0

新角TDD,和我得到一個錯誤,對此我無法調試,任何見解將是有益的誤差角JS服務TDD

我有一個服務文件

angular.module('myApp') 
.service('usersLocationService', function() { 
    this.SetLocation = function (place) { 
     var address = {}; 
     //some code 
     return address; 
    }; 
}); 

我的人緣.conf.js有這個

files: [  
    'test/unitTest/spec/client/lib/angular.min.js', 
    'test/unitTest/spec/client/lib/angular-mocks.js', 
    'public/Services/*.js', 
    'test/unitTest/spec/client/**/*.js' 
], 

我的測試文件是

"use strict"; 
describe('Test Suite for UserLocationService', function() { 
var usersLocationService, httpBackend; 

beforeEach(inject(function ($httpBackend, _usersLocationService_) { 
    module('myApp'); 
    usersLocationService = _usersLocationService_; 
    httpBackend = $httpBackend; 
})); 


it('Should return the address from the google location place', function() { 
    var place = {}; 
    var data = this.usersLocationService.SetLocation(place); 
    console.log(place); 
}); 
}); 

,我得到的錯誤是

錯誤:[$注射器:NOMOD] http://errors.angularjs.org/1.5.7/ $噴油器/ NOMOD P0 = MyApp來 在C:/project/test/unitTest/spec/client/lib/angular.min .js:6

這個錯誤出現在主服務文件中,而不是在specFile中,爲了確認,我將服務文件中的值更改爲myServices,角度錯誤成爲nomod?p0 = myServices。我錯過了任何需要添加的庫嗎?

+0

嘗試刪除'',並添加'beforeEach(模塊( '對myApp'));前'beforeEach(注(功能'( $ httpBackend,_usersLocationService_' – varit05

+0

我之前嘗試過,beforeEach(module('myApp')); beforeEach(inject)之前,沒有工作,什麼是remove''? –

+0

您是否刪除了模塊('myApp') ;當你嘗試? – varit05

回答

0
在我的服務文件

當我寫的代碼如下它工作得很好

angular.module('myApp',[])