Simulating text entry with reactJs TestUtils Simulating text entry with reactJs TestUtils reactjs reactjs

Simulating text entry with reactJs TestUtils


By setting nameInput.props.value = 'a'; you are not actually updating the value in your component.

You should use React.addons.TestUtils.Simulate.change(nameInput, { target: { value: 'a' } }); or something similar to simulate modifying the actual value.


I found that this syntax works better for me:

  const emailInput = component.refs.userEmailInput;  emailInput.value = 'test@gmail.com';  Simulate.change(component.refs.userEmailInput);

The second line updates the input with the text, 'test@gmail.com'. The last line triggers the change.