easy-peasy
                                
                                 easy-peasy copied to clipboard
                                
                                    easy-peasy copied to clipboard
                            
                            
                            
                        mockActions:true calls thunks
i want to check whether a certain action / thunk is dispatched, so i set mockActions: true.
but i see that if the action is a thunk, it executes it.
Is this intentional? i think no thunk should be executed
What exactly are you testing?
An action is not the same thing as a thunk. This is why when mocking actions, thunks aren't mocked. That property is meant for when you're testing thunks.
If you're testing components that utilize said thunks, you should mock the hooks that import them instead.
@LuisOsta i am testing a hook that uses a easy-peasy action and i am only interested in whether this action is triggered. it happens to be a thunk action, but that does not matter as it is transparent for the caller
Hey @macrozone , Oh okay, that makes sense! The best practice when testing your own custom hook is to mock any other external hooks it relies upon.
So you'd do something like this in your test (assuming jest)
jest.mock("../../../store/", () => ({
  useStoreActions: () => mockedThunkName,
}));
Does that help?
PS I understand the confusion as to why thunks are not considered "actions" as you access them via the same hook as other actions. But fundamentally in Redux's actions and thunk are completely different things. This is why they're usually handled differently during mocking.