vendredi 14 juin 2019

Jest/Enzyme ReactNative how can I test the state in a functional component

I have a functional component which use useState in it. How can I test its state through jest?

I tried:

test('Test state', () => {
      const wrapper = shallow(<MyComponent {...props}/>)
      console.log(wrapper.state())

I receive this error:

ShallowWrapper::state() can only be called on class components

Aucun commentaire:

Enregistrer un commentaire