Angular 如何检查角度中的占位符内容?
我有以下html代码:Angular 如何检查角度中的占位符内容?,angular,typescript,testing,Angular,Typescript,Testing,我有以下html代码: <input formControlName="firstName" type="text" class="form-control" placeholder="Please enter the First Name"> </div> 您可以使用getAttribute() 使用.placeholder(如果需要键入,可能需要转换为HTMLInp
<input formControlName="firstName" type="text" class="form-control"
placeholder="Please enter the First Name">
</div>
您可以使用
getAttribute()
使用
.placeholder
(如果需要键入,可能需要转换为HTMLInputElement
)。
expect(fixture.nativeElement.querySelector('input[formcontrolname="firstName"]').value)
.toContain("John");
expect(element.getAttribute("placeholder")).toEqual("Please enter the First Name")