postman 中斷言時間的方法
阿新 • • 發佈:2019-01-01
var startTime="2018-11-13 00:00:00"; var time2 = Date.parse(new Date(startTime)); time2 = time2 / 1000; console.log(time2) var endTime="2018-11-18 00:00:00"; var time3 = Date.parse(new Date(endTime)); time3 = time3 / 1000; console.log(time3) pm.test("Response time is less than endtime", function () { var jsonData = pm.response.json(); var responsetime = jsonData.data.list[1].createTime; responsetime = Date.parse(new Date(responsetime)); responsetime = responsetime / 1000; pm.expect(responsetime).to.be.below(time3); }); var jsonData = pm.response.json(); var responsetime = jsonData.data.list[1].createTime; responsetime = Date.parse(new Date(responsetime)); responsetime = responsetime / 1000; tests['respontime large starttime'] = responsetime > time2;