1
如何在React中测试类组件
我正在尝试一些单元测试,我用一个伪造的示例https://codesandbox.io/s/wizardly-hooks-32w6l创建了一个沙箱(实际上我有一个表单) class App extends React.Component { constructor(props) { super(props); this.state = { number: 0 }; } handleSubmit = (number1, number2) => { this.setState({ number: this.handleMultiply(number1, number2) }) } handleMultiply = (number1, number2) => { return number1 * number2 } render() { const { number } = this.state; return ( <div …