{
"data": {
"notifications": [
{
"deeplink": "/users/1628507341",
"viewed": false
}
]
},
"status": "success"
}
如何编写Postman测试来验证如下所示的deep - plink结果。
我已经知道深度链接ID,我想与字符串"users"合并
pm.test("notification deeplink is correct", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.data.notifications[0].deeplink).to.eql("/users/" + {{deeplink}});
});
您可以使用pm.variables.get("variable_name")
从Postman脚本中的变量中获取值
let deeplink = pm.variables.get("deeplink");
pm.test("notification deeplink is correct", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.data.notifications[0].deeplink).to.eql("/users/" + deeplink);
});