It does not seem like redux is being mocked (looking for mockImplementation in react redux)
In the code below I've listed all moving parts of the test
You need to import the react-redux library
You need to mock the function
You need to add the mockImplementation to provide a response value
Having all three pieces should make it work.
import{useSelector}from"react-redux";jest.mock("react-redux",()=>({...jest.requireActual("react-redux"),useSelector:jest.fn(),}));describe("MySearchComponent",()=>{beforeEach(()=>{useSelector.mockImplementation(callback=>{returncallback(mockAppState);});});test(()=>{// Your test here});});
mockAppState is the mocked redux state that your component needs to be able to run.
It should include data for all redux nodes that the component is using.
It does not seem like redux is being mocked (looking for mockImplementation in react redux)
In the code below I've listed all moving parts of the test
Having all three pieces should make it work.
what is "mockAppState"? can you please explain me more?
mockAppState
is the mocked redux state that your component needs to be able to run.It should include data for all redux nodes that the component is using.
Take a component like this:
A mocked app state for the above component would look like this:
So that you can run tests against a state that you have full control over.