Testing TextInput Component in react-native

后端 未结 3 1352
感情败类
感情败类 2021-01-19 06:26

I have some problems with testing TextInput changes in react-native with jest and enzyme.

My component that handles user input basi

3条回答
  •  离开以前
    2021-01-19 07:12

    I was able to do this using react-native-testing-library.

    // ...
    import { render, act, fireEvent } from 'react-native-testing-library'
    // ...
    it ('does stuff', () => {
      const mock = jest.fn()
      const component = render()
      fireEvent.changeText(component.findByType(TextInput), 'test')
      expect(mock).toHaveBeenCalledWith('test')
    })
    
    

提交回复
热议问题