angularjs - $timeout.flush TypeError: Cannot read property '$$nextSibling' of undefined -


i have segment of code inside $timeout executes promise. when write unit test use $timeout.flush() , can go inside $timeout block. promise resolved (since $timeout calls $scope.$apply() internally) after method code finishes , bubbles jasmine error typeerror: cannot read property '$$nextsibling' of undefined. else experienced before?

controller code:

$scope.timeoutfunction = function(){     $timeout(function () {         $scope.callfunction().then(function () {             callanotherfunction();         });     }, 0); } 

unit test code:

$scope.timeoutfunction();  scope.$digest(); // not needed  $timeout.flush(); // tried $timeout.flush(0); 

also if mock timeout callback function works. example:

function mockedtimeout() {     arguments[0](); }  $timeout = mockedtimeout; 

then use $scope.$digest promises called, timeout runs immediately. angular bug?

complete error stack:

typeerror: cannot read property '$$nextsibling' of undefined @ n.$get.n.$digest (http://localhost:51679/referencefile?path=d:\development\projects\website\scripts\libs\angular\angular.min.js:124:101) @ n.$get.n.$apply (http://localhost:51679/referencefile?path=d:\development\projects\website\scripts\libs\angular\angular.min.js:126:293) @ object.fn (http://localhost:51679/referencefile?path=d:\development\projects\website\scripts\libs\angular\angular.min.js:139:3) @ function.angular.mock.$browser.self.defer.flush (http://localhost:51679/referencefile?path=d:\development\projects\website\scripts\tdd\angular-mocks.js:127:42) @ function.angular.mock.$timeoutdecorator.$delegate.flush (http://localhost:51679/referencefile?path=d:\development\projects\website\scripts\tdd\angular-mocks.js:1732:28) @ null.<anonymous> (http://localhost:51679/tests.js:254:18) @ jasmine.block.execute (http://localhost:51679/referencefile?path=d:\development\projects\website\scripts\jasmine.js:1064:17) @ jasmine.queue.next_ (http://localhost:51679/referencefile?path=d:\development\projects\website\scripts\jasmine.js:2096:31) @ jasmine.queue.start (http://localhost:51679/referencefile?path=d:\development\projects\website\scripts\jasmine.js:2049:8) @ jasmine.spec.execute (http://localhost:51679/referencefile?path=d:\development\projects\website\scripts\jasmine.js:2376:14)" 


Comments