lundi 14 décembre 2020

How to check placeholder content in Angular?

I have the below html code:

 <input formControlName="firstName"  type="text" class="form-control"
      placeholder="Please enter the First Name">
  </div>

I want to do a component test where I check if the placeholder contains: "Please enter First Name".

The below code only returns the value. Is there a way to get the placeholder content?

 expect(fixture.nativeElement.querySelector('input[formcontrolname="firstName"]').value)
.toContain("John");

Aucun commentaire:

Enregistrer un commentaire