Closed lemiesz closed 1 year ago
Title should say jest not recognizing string template reducer.
jest
I have my reducer defined as such (simplified from real world use case to maintain main point)
export const setItem = createAction('@common//setItem'); const reducer = handleActions( { [`${setItem}`]: (state, action: Action) => !action.error ? action.payload : state, //other actions not shown }, null, );
This is a convenient way of reference the action type in sync with the defined action.
Problem is this seems to not work properly in jest. When defined this way the action is never triggered.
If I rewrite it to statically reference the action type
const reducer = handleActions( { [`@common/setItem`]: (state, action: Action) => !action.error ? action.payload : state, //other actions not shown }, null, );
This executes properly.
Anyway have any idea how I might fix this?
You should be able to reference the action with setItem.toString(). If this is still an issue feel free to comment and I will reopen it.
setItem.toString()
Title should say
jest
not recognizing string template reducer.I have my reducer defined as such (simplified from real world use case to maintain main point)
This is a convenient way of reference the action type in sync with the defined action.
Problem is this seems to not work properly in jest. When defined this way the action is never triggered.
If I rewrite it to statically reference the action type
This executes properly.
Anyway have any idea how I might fix this?