0

我是反应编程的新手。我正在为 redux 连接组件编写测试用例。所以我收到了来自不同减速器的道具。我正在使用 jest 和 react 测试库来编写测试用例。我正在使用 redux-mock-store 来模拟存储数据,但这不起作用。

TestComponent:
import customerInfo from './customerInfo.json'
import appInfo from './appInfo.json'

const middlewares = []
const mockStore = configureStore(middlewares)
const initialState = {
    customerInfo:customerInfo,
    appInfo:appInfo
}

let appStore = mockStore(initialState)

   render(
        <Provider store={appStore}>
            <PersistGate loading={null} persistor={persistor}>
                <Router history={newHistory}>
                    <Home/>
                </Router>
            </PersistGate>
        </Provider>
    );


HomeComponent:

<Home/>

const mapStateToProps = (state) => {
  return {
    appInfo: state.appReducer.appInfo,
    customerInfo: state.userReducer.customerInfo
  };
};
4

0 回答 0