I have a function that calls useSelector multiple times upon rendering. In mocking the selector I used:
jest.spyOn(Redux, 'useSelector').mockReturnValueOnce(data).mockReturnValueOnce(moreData);
This changes the order of how hooks are called in my component. I have also tried creating a mock store and sending that into rendered component in the test as such:
const state = { userGuid: 'testGuid', user };
const store = mockStore(state);
jest.spyOn(Redux, 'useSelector').mockImplementation(() => store.getState());
const { getByTestId } = wrappedRender(ProfileScreen, mockProps, { store });
But this wraps the data in an extra object which my component cannot de-structure.
As of now I cannot find any other way to mock the return values of multiple useSelector calls without changing the order of hooks called. Any help is appreciated.