각도 1.48 -> 1.61 에서 마이그레이션을 시작했습니다. 통과를 거부하는 단위 테스트가있었습니다. 우리가 작성한 지시문이 향후 require 속성으로 항상 변경되지 않도록 변경되지 않을지 확인하고자합니다. 여기
는 지시어 정의입니다 :angular.module('ourApp')
.directive('ourdirective', ['$timeout', function($timeout) {
return {
restrict: 'AE',
require: 'ngModel',
scope: {
options:'=?',
max:'=',
ngModel : "="
},
templateUrl: 'ourhtmltemplate.html'
link: function(scope, elt, attrs, ctrl) { // some code here }
그리고 여기에 우리는 그 일에 대해 쓴 단위 테스트입니다. 어떤 종류의 컴파일 오류도 없다고 가정 할 수 있으며 다른 테스트가 많이 오르고 있다고 가정 할 수 있습니다.
it('should throw if no ng model present', function() {
expect(function() {
buildElement("<ourdirective ></ourdirective>");
}).toThrowError();
};
function buildElement(html) {
element = angular.element(html);
$compile(element)($rootScope);
$rootScope.$digest();
$rootScope.select = {}
isolatedScope = element.isolateScope();
$rootScope.$apply(function() {});
}
우리는 다음과 같은 패키지를 사용하고 있습니다 :
"각도": "1.6.1", "각-망신 시켰습니다": "1.6.1", "자스민-기대": "1.22 ", "karma ":"^ 0.12.31 ", "karma-jasmine ":"^ 0.3.5 ", "karma-jasmine-matchers ":"^ 0.1.3 ", "karma-phantomjs- 실행기 ":"^ 0.1.4 ",
어떤 도움이 가장 apritiated 것입니다.