Unit testing 如何对深度连接的redux组件进行单元测试?
我试图包装我的组件以使用提供程序进行测试,并使用react test rendererUnit testing 如何对深度连接的redux组件进行单元测试?,unit-testing,redux,Unit Testing,Redux,我试图包装我的组件以使用提供程序进行测试,并使用react test rendererrenderer.create()对其进行深度渲染。在本例中,mapStateToProps工作正常,但我无法使用mapDispatchToProps获得预期的结果。在这里,被测试的组件呈现其他连接的组件 我的mapDispatchToProps看起来像 /* @flow */ import { bindActionCreators } from 'redux'; import type { Dispatch
renderer.create()
对其进行深度渲染。在本例中,mapStateToProps工作正常,但我无法使用mapDispatchToProps获得预期的结果。在这里,被测试的组件呈现其他连接的组件
我的mapDispatchToProps看起来像
/* @flow */
import { bindActionCreators } from 'redux';
import type { Dispatch } from './types';
import * as actions from './actions';
export default (dispatch: Dispatch, ownProps: Object): Object => ({
actions: bindActionCreators(actions, dispatch),
});
此处返回的操作
值为未定义
store.js
import { applyMiddleware, compose, createStore } from 'redux';
import { autoRehydrate } from 'redux-persist';
import thunk from 'redux-thunk';
import rootReducer from './reducers';
import { REHYDRATE } from 'redux-persist/constants';
const store = compose(autoRehydrate(), applyMiddleware(thunk, createActionBuffer(REHYDRATE)))(createStore)(rootReducer);
导出默认存储