Go Pro Sign Up Login
0 days 0 hrs 0 min 0 sec

Summer Sale

50% off Level Up Pro until you unsubscribe.
Get access to ALL 128 courses on Level Up Tutorials

This is your last chance to get Level Up Pro for $145/year.

or Learn More
Moon Moon

Buy Now and unlock this series




yours forever

Become a Pro and unlock everything




per month

Form Events With Controlled Inputs

In this video we will be dealing with form event and controlled inputs. We will continue to use mocking functions and spies


Become a pro to download code and videos


Ian Lunn

about 2 years ago

Another (perhaps cleaner) option for changing the input value is by using @testing-library/user-event: https://github.com/testing-library/user-event

You import as follows:

import userEvent from "@testing-library/user-event";

Then write the event to change the input value to "hello" with:

userEvent.type(getByLabelText("Text"), "hello");

Fabio Montone

about 2 years ago

Wanna see something strange? onChange works with 'react-testing-library' import bot it doesn't work with '@testing-library/react'. I thought @testing-library/react was newer and up-to-date.

User avatar


over 2 years ago

Loving this course. Thanks a ton, Scott!

Ausar McGruder

over 2 years ago

This course has been great so far. I had to modify some stuff in the beginning from older dependencies..but overall, really good stuff.

User avatar


almost 3 years ago

@Arpita make sure you actually type in text in the label


almost 3 years ago

fireEvent.change(getByLabelText("username"), { target: { value: 'test' }, });

is not working for me

Want to join the conversation?

Become a Pro member today!