【问题标题】:Postman Tests: There was an error in evaluating the test script邮递员测试:评估测试脚本时出错
【发布时间】:2021-01-16 05:31:48
【问题描述】:

我正在测试应用程序并遇到此错误,我想在我的脚本中包含此错误,但我不知道如何操作。

这个错误发生是因为我在body写错了变量名,也是测试过程的一部分

我想做这样的事情:

pm.test("There was an error in evaluating the test script", 
    function(){
    pm.expect(??.??).to.eql("There was an error in evaluating the test 
    script:  JSONError: Unexpected token '<' at 1:1 <pre class="cake-error"> 
    <a href="javascript:void(0);" 
    onclick="document.getElem ^");
});

【问题讨论】:

    标签: testing postman postman-testcase


    【解决方案1】:

    这样就可以了:

    const resBody = pm.response.text();
    
    pm.test("There was an error in evaluating the test script", function(){ 
        pm.expect(resBody).to.include("There was an error in evaluating the test script: JSONError: Unexpected token '<' at 1:1 <a href=\"javascript:void(0);\" onclick=\"document.getElem ^");
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-21
      • 2018-10-07
      • 2021-05-13
      • 2019-05-14
      • 2020-03-21
      • 2021-10-26
      • 2019-08-05
      • 1970-01-01
      相关资源
      最近更新 更多