Framework7 React Jest Unit Test

I’m currently trying to write Unit test for F7 components, the setup is using React Context and useReducer. For testing I’m using Jest and @testing-library/react-hooks. I can successfully test Context and reducer, but can’t test the components or even any functions.

Again I’m new to Unit testing, and here is my test for one of the components:

// Framework7 parameters here
const f7params: Framework7Parameters = {
  id: "io.framework7.testapp", // App bundle ID
  name: "Test", // App name
  theme: "auto", // Automatic theme detection
  // App routes
  routes,
};

const state: istore = {
  redirect: false
}

const dispatch = jest.fn();

const wrapper: React.FC = ({ children }) => (
  <StateContext.Provider value={{ state, dispatch }}>
      <App {...f7params}>
        {children}
      </App>
  </StateContext.Provider>
);

const mockUseContext = jest.fn().mockImplementation(() => ({ state, dispatch }));

React.useContext = mockUseContext;

describe('Component test', () => {
  test('rendering HomePage', () => {
    const { result } = renderHook(() => HomePage(f7params), { wrapper });
    console.log(result.current)
  });
});

After running the test, I see that it’s getting stuck on params.f7router.app. The error says:

TypeError: Cannot read properties of undefined (reading ‘app’)

Do I need to mock the app params? Or is there any easier solutions?