let wrapper;
const setState = jest.fn();
const useStateSpy = jest.spyOn(React, "useState")
useStateSpy.mockImplementation((init) => [init, setState]);
beforeEach(() => {
wrapper = Enzyme.mount(Enzyme.shallow(<AddOption/>).get(0))
});
afterEach(() => {
jest.clearAllMocks();
});
I am trying to mock state however for this line -
useStateSpy.mockImplementation((init) => [init, setState]);
I am getting the error:
Type 'any[]' is missing the following properties from type '[unknown, Dispatch<unknown>]': 0, 1ts(2739)
I am unsure as to how to fix this error and haven't been able to find much online in relation to fixing an error like this for this particular use case.