【问题标题】:$compile: ctreq error not been thrown after upgrade to angular 1.61$compile: 升级到 Angular 1.61 后未抛出 ctreq 错误
【发布时间】:2017-02-03 01:38:14
【问题描述】:

我刚刚开始从 angular 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”, "业力": "^0.12.31", “业力茉莉花”:“^0.3.5”, “业力茉莉花匹配器”:“^0.1.3”, "karma-phantomjs-launcher": "^0.1.4",

任何帮助都将是最合适的。

【问题讨论】:

    标签: angularjs testing angularjs-directive karma-jasmine


    【解决方案1】:

    事实证明,这是 Angular 1.6 中的一个已知问题 https://github.com/angular/angular.js/issues/15629

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-02
      • 1970-01-01
      • 2013-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-05
      • 2021-01-21
      相关资源
      最近更新 更多