您如何测试没有回报的语句反应开玩笑酶
我正在学习开玩笑,酶,我只是无法弄清楚一些如此简单的东西。我的问题是,这种情况在另一个功能中。我需要检查状态OBJ是否不是null,然后分配一些变量并进行测试。当我检查代码覆盖范围时,它表明未涵盖IF语句。谢谢
async handleButton() {
if (this.state.obj !== null) {
var employee = this.state.obj.employee.name;
var employeeId = this.state.obj.employee.id;
}
await this.setState({
updateObj: {...someOldObj, employee, employeeId};
});
}
I am learning jest, enzyme and i just cant figure out something so simple. My problem is that this condition is inside of another function. I need to check if the state obj is not null then assign some variables and test it. When I check code coverage it shows that the if statement is not covered. thanks
async handleButton() {
if (this.state.obj !== null) {
var employee = this.state.obj.employee.name;
var employeeId = this.state.obj.employee.id;
}
await this.setState({
updateObj: {...someOldObj, employee, employeeId};
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论