How to spy on a class property arrow function using Jest
问题 How can I spy on a class property arrow function using Jest? I have the following example test case which fails with the error Expected mock function to have been called. : import React, {Component} from "react"; import {shallow} from "enzyme"; class App extends Component { onButtonClick = () => { // Button click logic. }; render() { return <button onClick={this.onButtonClick} />; } } describe("when button is clicked", () => { it("should call onButtonClick", () => { const app = shallow(<App /