Closed vladimir-ivanov closed 5 years ago
We probably won't provide any mocks with the library. My preference is to add an actual provider and use the real store (or a mock store) but with all real redux-react-hook
. An alternative is to use Jest to mock out the module itself, which isn't too bad because mapState
returns the data you're looking for and dispatch
returns a function.
Something like this, if you use create
:
jest.mock('redux-react-hook', () => {
return {
create() {
return {dispatch: jest.fn(), mapState: jest.fn()};
}
};
});
For an example of testing with a real store, see the tests for redux-react-hook
itself: https://github.com/facebookincubator/redux-react-hook/blob/master/src/__tests__/index-test.tsx
Are there any plans to provide mocks for the store/ dispatch functions please? Can not find any examples of how to test components which connect to the store via redux-react-hooks
Thanks