Skip to content

REDUX THUNK breaks the test hepler #18

Description

@imperialdalek

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));
}`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions