Reactjs 使用和react测试库进行测试时未定义的历史对象
我有一个按钮,应该这样做:这个。道具。历史。点击时按下(PageA)。 但是,我得到了这个错误:Reactjs 使用和react测试库进行测试时未定义的历史对象,reactjs,jestjs,history.js,babel-jest,react-testing-library,Reactjs,Jestjs,History.js,Babel Jest,React Testing Library,我有一个按钮,应该这样做:这个。道具。历史。点击时按下(PageA)。 但是,我得到了这个错误:TypeError:无法读取未定义的属性“push”——这意味着历史记录未定义 这是我的设置,在每次测试税务组件之前运行 const initialState = { tax: { amount: 0.35 } }; function renderWithRedux( component, history = createMemoryHistory({
TypeError:无法读取未定义的属性“push”
——这意味着历史记录未定义
这是我的设置,在每次测试税务组件之前运行
const initialState = {
tax: {
amount: 0.35
}
};
function renderWithRedux(
component,
history = createMemoryHistory({ initialEntries: ['/app/dashboard'] }),
store = createStore(***createReducer(history), initialState, applyMiddleware(thunk))
) {
return {
...render(
<Provider store={store}>
<HelmetProvider>
<Router history={history}>
<Switch>{component}</Switch>
</Router>
</HelmetProvider>
</Provider>
),
store,
history
};
}
有没有其他方法来传递历史?我漏掉了一点吗?
非常感谢那些愿意帮助你的人。
任何带有示例或重要信息的链接将不胜感激:)
反应测试库:6.1.2
反应版本:16.8.6
净现值:6.9.0
combineReducers({
tax: taxReducer,
router: connectRouter(history)
});