Testing whether certain elements are visible or not

This behavior has changed in Angular 1.2 because of ng-animate.

The code for ngShow is:

var ngShowDirective = ['$animate', function($animate) {
  return function(scope, element, attr) {
    scope.$watch(attr.ngShow, function ngShowWatchAction(value){
      $animate[toBoolean(value) ? 'removeClass' : 'addClass'](element, 'ng-hide');
    });
  };
}];

Which means that it will add/remove class ng-hide to hide/show the element.

Thus, as an example, the right way to test if the element is hidden would be:

expect(element.find('.value-entry input').hasClass('ng-hide')).toBe(true);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)