I am currently facing an issue with my test where the onChangeText function does not update the value of the TextInput component as expected.
const TestComponent = ({onChangeText, value}) => {
return (<TextInput testID={'input'} onChangeText={onChangeText} value={value} />)
}
test('Update TextInput value on onChangeText', () => {
const onChangeText = jest.fn()
const value = 'initial input'
const { getByTestId } = render(
<TestComponent onChangeText={onChangeText} value={value} />
);
const input = getByTestId('input')
fireEvent.changeText(input, 'updated text');
expect(input.props.value).toBe('updated text');
});
The test result still shows the initial value 'initial input' instead of the updated value 'updated text'. How can we ensure that the value gets updated when using the onChangeText prop in our test?