내가하는 일이 완전히 잘못 되었다면 잘 모르겠지만, "지시어"에서 "구성 요소"로 전환하여 내 HTML 요소 몇 개를 정의하면 갑자기 내 모든 카르마가 파손되었습니다. 테스트. 여기에 내가 가진 무엇 :Basic Karma Angular 1.5 구성 요소 테스트
는
...
preprocessors: {
'module-a/module-a.view.html': ['ng-html2js'],
...,
'module-z/module-z.view.html': ['ng-html2js']
},
ngHtml2JsPreprocessor: {
moduleName: 'theTemplates'
},
...
모듈 a.component.js
(function(){
"use strict";
angular.module('ModuleA').component('moduleAComponent',{
controller: 'ModuleAController as moduleAVm',
templateUrl: 'module-a/module-a.view.html'
});
})();
모듈-A-tests.js을 karam.conf.js
"use strict";
describe('ModuleA',function(){
beforeEach(module('ModuleA'));
describe('Controller',function(){
...
});
describe('Component',function(){
var element, $rootScope;
beforeEach(module('theTemplates'));
beforeEach(inject([
'$compile','$rootScope',
function($c,$rs) {
$rootScope = $rs;
element = $c('<module-a-component></module-a-component>')($rootScope);
$rootScope.$digest(); // ???
}
]));
it('should have moduleAVm',function(){
expect(element.html()).not.toBe(''); // FAILS HERE
expect(element.html()).toContain('moduleVm'); // FAILS HERE TOO
});
});
});
오류 :
Expected '' not to be ''.
콘솔에 표시되는 오류를 추가 할 수 있습니까? 또한,이 angular.module ('ModuleA', [])로 시도해보십시오. component ('moduleAComponent'.... –
'module-a/module-a '에'angular.module ('ModuleA ', [])'을 정의했습니다. .module.js'이므로 괜찮아요.하지만 오류를 추가했습니다. 기대하는 호출에 실패했습니다. 즉, element.html()이 비어 있음을 의미합니다. 즉, 소화되지 않았 음을 의미합니다 ( – westandy