'state in useSelector is not covered in unit test

I have below code snippet:

const appInstances = useSelector(
        useCallback(
            (state) =>
                state.instances.filter(
                    x =>
                        x.parentInstanceId === instanceId),
            [instanceId]
        )
    );

I have the mock function to mock the return value for useSelector

 const useSelectorSpy = jest.spyOn(redux, 'useSelector');
        useSelectorSpy.mockReturnValue(appInstances);

However, in code coverage report it shows below parts are not covered:

(state) =>
                state.instances.filter(
                    x =>
                        x.parentInstanceId === instanceId),

How we can cover the missing part in test cases? Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source