我在Postman上有一个身体响应,它为我返回了这个:
[
{
"key": "Dateline Standard Time",
"value": "(UTC-12:00) International Date Line West"
},
{
"key": "UTC-11",
"value": "(UTC-11:00) Coordinated Universal Time-11"
},
{
"key": "Aleutian Standard Time",
"value": "(UTC-10:00) Aleutian Islands"
}]那么,在Tests选项卡中,如果响应的顺序完全相同,我应该写什么来测试呢?
我尝试了这样的东西:
pm.test("Body is correct", function(){
pm.response.to.have.body("
[
{
"key": "Dateline Standard Time",
"value": "(UTC-12:00) International Date Line West"
},
{
"key": "UTC-11",
"value": "(UTC-11:00) Coordinated Universal Time-11"
},
{
"key": "Aleutian Standard Time",
"value": "(UTC-10:00) Aleutian Islands"
}]
");但还是不起作用。
谢谢!
发布于 2021-03-26 09:17:18
pm.test("Body is correct", function () {
pm.expect(pm.response.json()).to.deep.equal(
[
{
"key": "Dateline Standard Time",
"value": "(UTC-12:00) International Date Line West"
},
{
"key": "UTC-11",
"value": "(UTC-11:00) Coordinated Universal Time-11"
},
{
"key": "Aleutian Standard Time",
"value": "(UTC-10:00) Aleutian Islands"
}]
)
});使用深度相等
https://stackoverflow.com/questions/66807648
复制相似问题