我正在尝试测试组件undecorator,但我没有。
示例:
import test from 'ava'
import Component from './Component'
import { mount } from 'enzyme'
test('<Component />', t => {
let wrapper = mount(<Component />) // the connect's redux create a wrapper component :(
})
示例测试:
{{1}}
可以测试未修饰的组件吗?怎么样?
答案 0 :(得分:2)
connect
生成的包装类将内部组件类公开为名为WrappedComponent
的静态字段,因此您可以单独测试它。请参阅https://github.com/reactjs/react-redux/blob/master/docs/api.md#static-properties。