React unit test: access methods and state props inside functional components with Jest Enzyme

I am trying to learn writing unit tests using jest, enzyme for functional based React components. I am trying to write unit tests for the methods defined inside functional components. Please can anyone help me with this?


const MyTable = ({allRows}) => {
    const [page, setPage] = useState(0);
    const [val, setVal] = useState(0);

    const handleClick = (index) => {
            //other logic

    const handleFilter = (event) => {
        //other logic

    return (
        <div className={classes.root}>
            <Paper className={classes.paper}>
                                        onClick={(event) => handleClick(event, row, index)}
                                            <TableCell> </TableCell>

export default MyTable;


// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more:
import '@testing-library/jest-dom';
import {configure} from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';

configure({adapter: new Adapter()});


describe('<MyTable />', () => {
    let wrapper;
    let mockData = [{ id: 'id1' }, { id: 'id2' }]

    beforeAll(() => {
        wrapper = shallow(

    it('handleClick Test', () => {
       const spy = jest.spyOn(wrapper.instance(), "handleClick");

ERROR: TypeError: Cannot read property 'handleClick' of null

I also tried to console.log(wrapper.instance()) but it is returning null I also tried to access state props but it says ShallowWrapper::state() can only be called on class components

Any help is appreciated