我想检查具体响应 header (“位置”)中的值作为 Postman 中的测试结果。 在 Postman 的文档中,我找到了如何检查 header 是否存在的示例
pm.test("Content-Type is present", function () {
pm.response.to.have.header("Content-Type");
});
但我正在寻找的是类似
pm.test("Location value is correct", function () {
CODE HERE THAT CHECKS "Location" HEADER EQUALS TO SOMETHING;
});
最佳答案
我终于找到了解决方案:
pm.test("Redirect location is correct", function () {
pm.response.to.have.header("Location");
pm.response.to.be.header("Location", "http://example.com/expected-redirect-url");
});
关于testing - 在 Postman 测试中检查响应 header 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49253142/