邮递员测试:评估测试脚本时出错

时间:2020-09-30 14:07:44

标签: testing postman postman-testcase

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

此错误发生,因为我正文上输入了错误的变量名,这也是测试过程的一部分

我想做这样的事情:

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 ^");
});

1 个答案:

答案 0 :(得分:0)

这可以做到:

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 ^");
});
相关问题