내 Angular.js 응용 프로그램에 대한 단위 테스트를 작성하려고하지만 필요한 항목을 주입 할 수 없습니다 (적합한 공급자를 찾을 수 없음).테스트를위한 누락 된 주입 (알 수없는 공급자)
나는 누구를보고 싶니?
Firefox 21.0 (Linux) filter staticList should convert static list object into its display value FAILED
Error: Unknown provider: staticListProvider <- staticList in /path/to/my-app/public/third-party/angular/angular.js (line 2734)
createInjector/providerInjector<@/path/to/my-app/public/third-party/angular/angular.js:2734
[email protected]/path/to/my-app/public/third-party/angular/angular.js:2862
createInjector/instanceCache.$injector<@/path/to/my-app/public/third-party/angular/angular.js:2739
[email protected]/path/to/my-app/public/third-party/angular/angular.js:2862
[email protected]/path/to/my-app/public/third-party/angular/angular.js:2880
[email protected]/path/to/my-app/test/lib/angular/angular-mocks.js:1778
[email protected]/path/to/my-app/test/lib/angular/angular-mocks.js:1764
@/path/to/my-app/test/unit/filtersSpec.js:19
@/path/to/my-app/test/unit/filtersSpec.js:16
@/path/to/my-app/test/unit/filtersSpec.js:3
애플리케이션 :
angular.module('myApp', ['myAppFilters', 'ui.bootstrap', '$strap.directives']).
// Some other stuff
필터 :
"use strict";
angular.module('myAppFilters', []).
filter('staticList', function() {
return function (listItem) {
if (!listItem) {
return '';
}
return listItem.value;
};
});
시험 :
'use strict';
describe('filter', function() {
beforeEach(angular.module('myAppFilters'));
describe('staticList', function() {
it('should convert static list object into its display value',
inject(function (staticList) {
expect(undefined).toBe('');
expect({key: 'A', value: 'B'}).toBe('B');
}));
});
});
카르마 구성 :
사람이 전체 코드를보고 싶어하면basePath = '../';
files = [
JASMINE,
JASMINE_ADAPTER,
'public/third-party/jquery/*.js',
'public/third-party/angular/angular.js',
'public/third-party/angular/i18n/angular-*.js',
'public/third-party/moment/moment.min.js',
'public/third-party/moment/moment-*.js',
'public/js/**/*.js',
'test/lib/**/*.js',
'test/unit/**/*.js'
];
colors = true;
autoWatch = true;
browsers = ['Firefox'];
junitReporter = {
outputFile: 'test_out/unit.xml',
suite: 'unit'
};
, 응용 프로그램 저장소는 여기에 있습니다 : https://github.com/adericbourg/GestionCourrier
고마워,
알반
나는 그 지점을 놓쳤다. 고마워요! –
Thx! 이것은 문서에서 더 분명해야합니다. – Simon