【发布时间】:2018-12-23 09:23:32
【问题描述】:
我的async componentdidmount 中有以下代码:
async componentDidMount() {
try {
let responseText = await API.Licensing()
this.setState({ html: responseText })
} catch (e) {
this.setState({ html: 'Error Fetching Licensing Info' })
}
}
我一直对如何在这里测试 setstate 感到困惑,因为互联网上的大多数示例都使用 promise then/catch 而这个使用 try/catch async/await。
测试会是什么样子?
【问题讨论】: