angularjs-timeout

Simulate the passage of time in protractor?

北城余情 提交于 2019-12-19 03:38:13
问题 I have a few spots where things happen in the UI on a delay using $timeout or $interval. Here's a simplified example: Controller code : $timeout(function() { $scope.showElement = true; }, 10000); HTML : <div id="myElement" ng-show="showElement"></div> I want to be able to create an end-to-end Protractor test that tests whether #myElement gets displayed after a 10 second wait. The only way I have found to do this is to call browser.sleep(10000), which results in an actual 10-second delay in my

angularjs save changes after digest has finished

社会主义新天地 提交于 2019-12-11 02:22:52
问题 I think this might be quite common use-case with any angular app. I am simply watching some objects on my scope that are changed as part of several digest cycles. After digesting them (changing their values via databinding) has finished, I want to save them to databse. A. Now, with the current solutions I see following problems: running save in $timeout() - how to assure that save is called only once running a custom function in $scope.$evalAsync - how to find out what has been chaged There

Simulate the passage of time in protractor?

心不动则不痛 提交于 2019-11-30 23:03:21
I have a few spots where things happen in the UI on a delay using $timeout or $interval. Here's a simplified example: Controller code : $timeout(function() { $scope.showElement = true; }, 10000); HTML : <div id="myElement" ng-show="showElement"></div> I want to be able to create an end-to-end Protractor test that tests whether #myElement gets displayed after a 10 second wait. The only way I have found to do this is to call browser.sleep(10000), which results in an actual 10-second delay in my test. This works, but these pauses add up add up and significantly increase the duration of my tests.

What&#39;s the difference between $evalAsync and $timeout in AngularJS?

荒凉一梦 提交于 2019-11-26 00:45:44
问题 I\'ve been using AngularJS for a little while now, and have found the need to use $timeout every once in a while (Seems to usually be to init a jQuery plugin). Recently, I\'ve been trying to get a better and more in-depth understanding of the digest cycle, and I came across $evalAsync function. It seems like that function produces similar results to $timeout , only you don\'t give it delay. Every time I\'ve used $timeout it has been with a delay of 0, so now I\'m wondering if I should have