2013-11-05 3 views
1

나는 단지 갈마가 재스민으로 각도 응용 프로그램을 테스트하도록 설정하려고합니다. 이 오류를 받고 있어요 :각도를 시험 할 재스민 & 카르마 설정

INFO [karma]: Karma v0.10.4 server started at http://localhost:9876/ 
INFO [launcher]: Starting browser Chrome 
INFO [Chrome 30.0.1599 (Mac OS X 10.9.0)]: Connected on socket pxDaOUXMfGXOVL7ZOuPb 
Chrome 30.0.1599 (Mac OS X 10.9.0) ItemCtrl should work FAILED 
    TypeError: Object [object Object] has no method 'off' 
     at null.<anonymous> (/Users/macbookpro/Sites/groceries/spec/angular-mocks.js:1917:36) 

여기 그 함수의 angular-mocks.js에 :

afterEach(function() { 
    var injector = currentSpec.$injector; 

    currentSpec.$injector = null; 
    currentSpec.$modules = null; 
    currentSpec = null; 

    if (injector) { 
     injector.get('$rootElement').off(); 
     injector.get('$browser').pollFns.length = 0; 
    } 

    angular.mock.clearDataCache(); 

    // clean up jquery's fragment cache 
    angular.forEach(angular.element.fragments, function(val, key) { 
     delete angular.element.fragments[key]; 
    }); 

    MockXhr.$$lastInstance = null; 

    angular.forEach(angular.callbacks, function(val, key) { 
     delete angular.callbacks[key]; 
    }); 
    angular.callbacks.counter = 0; 
    }); 

난 그냥 내 카르마 설정에 잘못된 순서로 파일을 필요로하는 것 같아요. 여기 내 파일 구조는 다음과 같습니다

karama.config.js 그것이 필요 년대 파일과 같은 디렉토리 /spec에 있습니다

// list of files/patterns to load in the browser 
    files: [ 
     'angular.min.js', 
     'angular-mocks.js', 
     'app_testable.js', 
     'app_spec.js' 
    ], 

app_testable.js는 각도를 제외한 종속되지 내 응용 프로그램의 버전을 박탈입니다. 내 시험이있다. 그냥 truetrue이되도록 노력하고 있습니다.

'use strict'; 

describe('ItemCtrl', function(){ 
    var scope; 
    beforeEach(angular.mock.module('Grocerease')); 
    beforeEach(angular.mock.inject(function($rootScope, $controller){ 
     scope = $rootScope.$new(); 
     $controller('ItemCtrl', {$scope: scope}); 
    }) 
); 

    it('should work', function(){ 
    expect(true).toBe(true); 
    }); 

}); 

테스트를 올바르게 실행할 수 있도록 카르마를 설정해야하는 이유는 무엇입니까?

+0

jquery를 사용하고 있습니까? – dimirc

+0

아니요. 사용중인 파일 만 위에 나열되어 있습니다. 옆으로, 나는 라우터 모듈을 사용하지 않기 때문에 각 리소스를 포함하지 않았다. 그게 필요한가요? – nickcoxdotme

+0

angular-resource는 라우터 모듈이 아니라 REST API의 "리소스"를 처리합니다. index.html – dimirc

답변

5

종속성이 잘못로드 된 것 같습니다.

어떤 각도로 작업 하시겠습니까? '각도'및 '각도 모의'파일은 동일한 버전이어야합니다.

+0

+1 나를 위해 해결 된 것 : 버전이 일치하는지 확인하십시오! –

+0

감사합니다. 몇 시간 동안 디버깅을 저장해 두었습니다. – LiorH

관련 문제