Questions tagged «jestjs»

Jest是Facebook基于Jasmine制作的JavaScript单元测试框架,并提供了自动模拟创建和jsdom环境。它通常用于测试React组件。

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 …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.