【发布时间】:2020-09-21 02:34:02
【问题描述】:
问题: 在 Postman 中,我正在运行一个 POST 请求并尝试将我在响应正文中收到的内容断言为通过 CSV 文件传递的内容。
CSV 文件包含三列:employee_name、employee_salary 和employee_age。所有设置为通用格式(默认)。
断言对employee_name 工作正常,但是当我尝试对employee_age 和employee_salary 执行此操作时,我收到如下错误: AssertionError: 预期 '35' 等于 35
Here 是我正在使用的 API。
我尝试过的: 我尝试将 CSV 文件中的年龄和薪水单元格的格式设置为文本和数字,但无济于事。
代码:
var jsonData = pm.response.json();
pm.test("Verify name", function() {
pm.expect(jsonData.data.name).to.equal(pm.iterationData.get("employee_name"));
});
pm.test("Verify age", function() {
pm.expect(jsonData.data.age).to.equal(pm.iterationData.get("employee_age"));
});
pm.test("Verify salary", function() {
pm.expect(jsonData.data.salary).to.equal(pm.iterationData.get("employee_salary"));
});
感谢您的帮助!
最好, 杰森
【问题讨论】:
-
看起来它失败了,因为 '35' 是一个字符串,而 35 是一个数字
标签: javascript postman