javascript - 结合两个对单个 json 响应执行检查的期望语句
问题描述
我正在编写一个测试来检查我的 Node.js 应用程序中返回此JSON
结构的函数:
}
id: 1,
name: 'John Doe',
email: 'j@doe.com',
phone: '+123',
suppliers: [
{
id: 1,
name: 'Supplier1'
}
]
}
我有这个expect
:
expect(res.body.users[0]).to.be.an.instanceof(Object)
.that.includes.all.keys([
'id',
'name',
'suppliers',
]);
我还想查看 中是否有详细信息suppliers
。我可以在另一个中添加这个expect
:
expect(res.body.users[0].suppliers[0]).to.be.an.instanceof(Object)
.that.includes.all.keys([
'id',
'name',
]);
是否可以将两者合并为一个expect
语句?
解决方案
推荐阅读
- c# - 如何从在 startup.cs 中构建 serviceProvider 的类库中获取 IServiceProvider?
- c# - 发布者的 RabbitMQ Ack
- python - 在 tkinter 后台执行功能
- vue.js - Vue-Router 在选择选项中不起作用
- filter - 卷积效果从 Gimp 版本 2.8.22 更改为 2.10.18
- c# - 组合框值发生变化,但在视觉上 SelectedValue 保持不变
- java - MongoDB的查询条件传入时按日期降序排序时如何限制(1)记录
- java - 使用java生成drools drl文件
- mysql - Crontab 不能与 `mysqldump: command not found` 一起工作 mac osx
- docker - 无法使用 Kubeadm 从 Kubernetes 集群连接 Azure 数据库