pm.sendRequest 在 post 请求中不起作用 邮递员测试

时间:2021-06-14 22:14:34

标签: postman postman-pre-request-script postman-testcase

我在集合级别预请求脚本中创建了一个方法,如下所示:

utils = {

  testPMReq : function() {
       console.log("I am here");
        pm.sendRequest("https://postman-echo.com/get", function (err, response) {
        console.log(response.json());
    }); 
  }
};

然后在请求后测试中使用此方法如下:

utils.testPMReq();

它打印出:“我在这里”,但它不执行 pm.sendRequest 调用。

当我调用 utils.testPMReq();在方法创建后的集合级别 pre-prequest 脚本中,它执行发送请求调用。

当我从发布请求脚本执行该方法时,有人可以帮助为什么 sendRequest 不起作用以及如何使其工作?

0 个答案:

没有答案