Jest / Enzyme ReactNative如何测试功能组件中的状态

时间:2019-06-14 10:23:46

标签: unit-testing react-native testing jestjs enzyme

我有一个使用useState的功能组件。如何通过玩笑来测试其状态?

我尝试过:

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

我收到此错误:

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

0 个答案:

没有答案