I have a reducer test that is passing but throwing out this weird error at the end:
console.error node_modules/redux/lib/utils/warning.js:14
No reducer provided for key "newProducts"
src/reducer/index.ts
import newLineItemReducer from "./newLineItemReducer";
import renewedLineItemReducer from "./renewedLineItemReducer";
export interface LineItemState{
renewedProducts: LineItem[]
newProducts: LineItem[]
}
//used by both reducers
export interface LineItem{
...
}
// used by both "new" and "renewed" slice reducers
export function sharedFunction1() {
...
}
export default combineReducers<LineItemState>({
renewedProducts: renewedLineItemReducer,
newProducts: newLineItemReducer
});
src/reducer/newLineItemReducer.ts
import {LineItem, sharedFunction1 } from "./";
type Action = ...;
const newLineItemReducer =
(state: LineItem[] = [], action: Action): LineItem[] => {
switch (action.type) {
case ...:
sharedFunction1(state, action.foo);
}
}
export default newLineItemReducer;
test/newLineItemReducer.spec.ts
import newLineItemReducer from "@src/reducers/newLineItemReducer";
test("foo", () => {
let state = //
let action = //
const updatedState = newLineItemReducer(state, action);
...
});
The weird thing is there is no code that is actually calling the root reducer from index. My test is directly calling the slice "newLineItemReducer". Seems like just the act of importing the shared interface and case function from reducer/index.ts is causing the issue (If I remove combineReducer export there is no error)?