Can't spy on an event handler even though I can spy on other methods
问题 I want to test an event handler in React using Jest/Jasmine/Enzyme. MyComponent.js : import React from 'react'; class MyComponent extends React.Component { constructor(props) { super(props); this.clickHandler = this.clickHandler.bind(this); this.otherMethod = this.otherMethod .bind(this); } clickHandler() { this.otherMethod(); } otherMethod() {} render() { return <div onClick={this.clickHandler}/>; } } export default MyComponent; MyComponent.test.js : import React from 'react'; import {mount}