Postman Tests: There was an error in evaluating the test script

2.1k views Asked by At

I am testing the application and face this error, I want to include this error in my script but I don't know-how.

This error happens because I write the wrong variable name on the body, and is also part of the process to test.

I want to do something like that:

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

There are 1 answers

0
Christian Baumann On

This will do it:

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