How to mock/spy useState hook in jest?
问题 I am trying to spy on useState React hook but i always get the test failed This is my React component: const Counter= () => { const[counter, setCounter] = useState(0); const handleClick=() => { setCounter(counter + 1); } return ( <div> <h2>{counter}</h2> <button onClick={handleClick} id="button">increment</button> </div> ) } counter.test.js : it('increment counter correctlry', () => { let wrapper = shallow(<Counter/>); const setState = jest.fn(); const useStateSpy = jest.spyOn(React,