Reactjs React JS Jest单元测试用于测试的酶设置状态
我正在为使用回流的react js组件编写一个jest和酵素单元测试 我最终得到了检查组件安装的测试,并用以下代码检查组件Reactjs React JS Jest单元测试用于测试的酶设置状态,reactjs,jestjs,enzyme,Reactjs,Jestjs,Enzyme,我正在为使用回流的react js组件编写一个jest和酵素单元测试 我最终得到了检查组件安装的测试,并用以下代码检查组件 **const onWillMount = jest.fn() MyComponent.protoType.componentWillMount = onWillMount mount(<MyComponent/>) expect(onWillMount).toHaveBeenCalled(1)** 这回答了你的问题吗?这回答了你的问题吗? export de
**const onWillMount = jest.fn()
MyComponent.protoType.componentWillMount = onWillMount
mount(<MyComponent/>)
expect(onWillMount).toHaveBeenCalled(1)**
这回答了你的问题吗?这回答了你的问题吗?
export default class MyComponent extends Reflux.Component {
constructor(props) {
super(props)
this.stores= ['myStore']
this.storeKeys = ['myDataList']
}
compentDidMount() {
myAction.getMyList()
}
render() {
const hasData = !_.isNil(this.state.myList)
}
}