Expected True To Equal False
I want to test something in angular that really is not in teh Anguar tutorial. I am trying to test that when the value of this input is invalid teh error message is outputted, so t
Solution 1:
The expression
fixture.debugElement.query(By.css('#ref')).nativeElement.hasAttribute('hidden')
reads as if it's testing if the #ref
element has an attribute named hidden
. If so, the result is unlikely to depend on the value of the attribute.
If the nativeElement
property is an HTMLElement in the DOM which always has a 'hidden' attribute, you should be able to get its value using
fixture.debugElement.query(By.css('#ref')).nativeElement.getAttribute('hidden')
However I have no way of conveniently verifying the data type of the attribute. If it is a string you should expect its value to be the string "false". If it is a boolean you probably need to expect its value to be the boolean value false
.
If you don't know the data type of the "hidden" attribute already, or how true and false are stored in the attribute, add some debugging code to establish the data type before proceeding further. Good luck!
Post a Comment for "Expected True To Equal False"