Angularjs $compile:ctreq错误在升级到angular 1.61后未引发
我刚刚开始从angular 1.48->1.61迁移 我带着一个拒绝通过的单元测试离开了。 我们希望验证我们编写的指令将来不会更改,因此它将始终保留require属性 以下是指令定义:Angularjs $compile:ctreq错误在升级到angular 1.61后未引发,angularjs,testing,angularjs-directive,karma-jasmine,Angularjs,Testing,Angularjs Directive,Karma Jasmine,我刚刚开始从angular 1.48->1.61迁移 我带着一个拒绝通过的单元测试离开了。 我们希望验证我们编写的指令将来不会更改,因此它将始终保留require属性 以下是指令定义: angular.module('ourApp') .directive('ourdirective', ['$timeout', function($timeout) { return { restrict: 'AE', require: 'ngModel',
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() {});
}
it('如果不存在ng模型,则应抛出',函数(){
expect(函数(){
buildElement(“”);
}).tothrowerr();
};
函数buildElement(html){
element=angular.element(html);
$compile(element)($rootScope);
$rootScope.$digest();
$rootScope.select={}
isolatedScope=element.isolateScope();
$rootScope.$apply(函数(){});
}
我们正在使用以下软件包:
“角度”:“1.6.1”,
“角度模拟”:“1.6.1”,
“茉莉花期”:“1.22”,
“因果报应”:“^0.12.31”,
“因果报应茉莉”:“^0.3.5”,
“因果报应茉莉配对者”:“^0.1.3”,
“karma phantomjs启动器”:“^0.1.4”
任何帮助都是最重要的。事实证明,这是angular 1.6中的一个已知问题