I am wondering how to test component that use react-hook-form. Control object is passed to children component DimensionInput
I used suggested in (How to call or mock useForm on jest react native?) solution but stil getting error
afterEach(() => {
cleanup();
});
it('renders correct text', () => {
jest.mock('react-hook-form', () => ({
...jest.requireActual('react-hook-form'),
Controller: () => <></>,
useForm: () => ({
control: () => ({}),
handleSubmit: () => jest.fn(),
}),
}));
const { control } = useForm({
mode: 'onChange',
});
const { queryByText } = render(
<DimensionsInput fieldId={'id'} buttonAction={null} control={control} />,
);
expect(queryByText('text')).toBeTruthy();
});
});```
my error Error:
```TypeError: Cannot read properties of undefined (reading '__H')```