How do I unit test if an element is visible when the *ngIf directive is used using Jasmine in Angular

前端 未结 4 1660
礼貌的吻别
礼貌的吻别 2020-12-28 15:28

I have an Angular 6 app and writing some unit tests trying to determine if an element is visible or not based solely on the boolean result of an *ngIf directive

4条回答
  •  梦谈多话
    2020-12-28 16:16

    When using ngIf, angular completely removes the node from markup. So you need to check that this element not exists.

    Documentation says:

    ngIf evaluates the expression and then renders the then or else template in its place when expression is truthy or falsy respectively.

    To be more precise, it's just not rendered

提交回复
热议问题