ThrowableException
ThrowableException

Reputation: 1426

Karate check if a phrase available in the response

I've a response

{ errors: [
       {
        code: 123,
        reason: "this is the reason1 is dynamically generated"
     }  ,
     {
        code: 234,
        reason: "this is the reason2 for another random reason"
     }
    ...
    ...
}

Now when I validate this response I use following

...
...    
And match response.errors[*].reason contains "this is the reason"

This validation fails, because there is an equality check for complete String for every reason with the phrase mentioned in the condition. this is reason1
I tried few wild cards but didn't work either, how to do it ?

Upvotes: 1

Views: 289

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

You missed each:

And match each response.errors[*].reason contains "this is reason"

Refer: https://github.com/karatelabs/karate#match-each

Upvotes: 1

Related Questions