score:12

Accepted answer

getByText looks by text content. value attribute is not text content but just one of attributes. So it will not find input by this approach.

Also it's kind of not idiomatic to search by thing you are going to assert for. Better find element by it's static properties and then check for dynamic value:

expect(getByTestId("useremail").value).toEqual("user@gmail.com");

PS To be more "RTL-approach" I'd also suggest to use getByPlaceholderText instead of getByTestId.


Related Query

More Query from same tag