Redux highlights an approach for testing connected components here, writing tests, that I follow but I keep getting this error:
Expected the reducer to be a function.
10 | {
11 | initialState,
> 12 | store = createStore(communityReducer, initialState),
| ^
13 | ...renderOptions
14 | } = {}
15 | ) {
This is the format of my reducer,
const communityReducer = (state = INITIAL_STATE, action) => {
switch (action.type) { ... }
}
that I import as:
import { communityReducer } from "../../reducers/communityReducer";
The component I am testing takes this format
const CommunityList = (props) => {
const { getCommunities, communityList } = props;
...
}
const mapStateToProps = (state) => ({
authReducer: state.authReducer,
communityReducer: state.communityReducer,
communityList: state.communityReducer.communityList,
});
export default connect(mapStateToProps, { getCommunities })(CommunityList);
getCommunities is an action
import { getCommunities } from "../../actions";
that takes this format:
export const getCommunities = () => async (dispatch) => {
....
};
Any idea why I get this error?
communityReducer. You are importing it as a named import (not default) but it doesn't appear to haveexportin front of it.export default communityReducer;at the end of the fileimport communityReducer from "../../reducers/communityReducer";instead ofimport { communityReducer } from "../../reducers/communityReducer";