-
Notifications
You must be signed in to change notification settings - Fork 564
Description
I have a query regarding the way to add ‘redux Thunk’ to the test_helper.js you explain and demonstrate in your videos.
Your original test_helper code has been tweaked to add redux thunk.
Having used ‘Redux Thunk’ in my project as demonstrated in another of your videos, I encountered an error in my tests due to them being wrapped by the ‘dispatch’ function in the action file.
MY attempt at changing test_helpers.js is below.
This produces a raft of abandoned promise error messages throughout the test result.
Please can you suggest a way to resolve this, or am I better off using Jest or Enzyme instead when using Redux Thunk?
Thanks in advance
`[I added these at top of script]
import { createStore, applyMiddleware } from 'redux';
import reduxThunk from 'redux-thunk';
[the updated function]
function renderComponent(ComponentClass, props = {}, state = {}) {
const createStoreWithMiddleware = applyMiddleware(reduxThunk)(createStore);
const componentInstance = TestUtils.renderIntoDocument(
<Provider store={createStoreWithMiddleware(reducers, state)}>
<ComponentClass {...props} />
);
return $(ReactDOM.findDOMNode(componentInstance));
}`