I have some problems with testing TextInput
changes in react-native with jest and enzyme.
My component that handles user input basi
There is no need to add another library. Jest and Enzyme can perform the required testing. Below is the definition of SearchBar component which receives a function as a prop. The function is called with the text typed.
const SearchBar = ({onSearch}) => {
return (
onSearch(text)}
/>
);
};
The testing can be carried as follows
const onSearch = jest.fn();
const wrapper = shallow( );
wrapper.find('TextInput').simulate('changeText', 'test search text');
expect(onSearch).toHaveBeenCalledWith('test search text');