1. angularjs
  2. karma
  3. jasmine

Test setup:

scope = $rootScope.$new(); ctrl = controller('tasksController',{$scope: scope}); element = angular.element('<tasks-component></tasks-component>'); view = $compile(element)(scope); scope.$digest(); 

And the test itself:

 console.log(view[0].querySelectorAll('.task')); // 5 элементов ctrl.tasks = [1]; scope.$digest(); console.log(view[0].querySelectorAll('.task')); expect(view[0].querySelectorAll('.task').length).toEqual(1); 

Template:

 <div class="task" ng-repeat="task in $ctrl.tasks> </div> 

Initially, there are 5 "tasks", after that I specify the change in the model via ctrl.tasks=[1] , after this the view does not change, there are still 5 elements. What am I doing wrong and how to update the view?

    0