$ rootScope.apply()导致Jasmine

时间:2015-12-29 13:11:56

标签: angularjs jasmine

我有一个关于Jasmine的规范正在触发错误:infdig当我调用$ rootScope.apply(),$ rootScope.digest()或$ httpbackend.flush()时。为简洁起见,我省略了代码,因为只有这一部分它才会触发错误:

describe("MyService", function() {

  beforeEach(module('my-module'));
  beforeEach(inject(function(_$rootScope_) {
    $rootScope = _$rootScope_;
  }));

  describe("test", function() {
    it("it loads something", function() {
      $rootScope.$apply();
    });

  });
});

这个简单的规范导致错误:

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!

调用堆栈是:

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.4.8/$rootScope/infdig?p0=10&p1=%5B%5D
    at angular.js:68
    at Scope.$digest (angular.js:15934)
    at Scope.$apply (angular.js:16160)
    at Object.<anonymous> (myServiceSpec.js:10)window.__karma__.result @ debug.html:38
debug.html:25 Skipped 0 tests

有关为何发生这种情况的任何想法?我正在使用Angular 1.4.8,使用Jasmine 2.4.1。

0 个答案:

没有答案
相关问题