I am using redux middleware and react testing library and was encountering an issue where I got this error (only when running my tests): Actions must be plain objects. Use custom middleware for async actions.
so I decided to pass in my redux middleware to my tests like so:
const middlewares = [thunk, api]
renderWithRedux = (ui, { initialState, store = createStore(reducers, initialState, composeEnhancers(applyMiddleware(...middlewares))) } = {}) => {
return {
...render(
<Provider store={store}>
{ui}
</Provider>,
),
store,
}
}
but now I get an error where the action in my middleware is coming through as undefined. I was wondering if there is a specific way to mock out custom middleware as I'm not trying to test that at the moment, Im trying to test one of my components and how it interacts and I need to mock out some of the actions for that to happen
Aucun commentaire:
Enregistrer un commentaire