【问题标题】:Unit test FormSection component单元测试 FormSection 组件
【发布时间】:2018-03-04 09:45:48
【问题描述】:

尝试用酶浅对redux-form FormSection组件进行单元测试,得到以下错误
Error: FormSection must be inside a component decorated with reduxForm()

避免此错误的最佳选择是什么?

【问题讨论】:

    标签: reactjs unit-testing jestjs redux-form enzyme


    【解决方案1】:

    我可以通过在上下文中模拟 reduxForm 来解决此错误,如下所示:
    shallow(<MyComponent {...props} />, { context:{ _reduxForm: {}}});

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-18
      • 2011-10-23
      • 2016-10-19
      • 2023-03-15
      • 1970-01-01
      • 2016-07-09
      • 2021-01-05
      • 1970-01-01
      相关资源
      最近更新 更多