Testing · Junior · Question 51 of 78

How do you type text into an input with user-event v14?

const user = userEvent.setup();
render(<Login />);
await user.type(screen.getByLabelText("Email"), "ann@example.com");

Explanation

In v14 all methods return promises. Setting value directly skips the events React listens to.

Further reading

Problem with a question

Testing · Junior · question 51

Test yourself

Take the Testing · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz