Karate: I would like to assert to match parts of response

Viewed 860

Karate: I would like to assert to match parts of response

I am getting the following response: 12:10:33.960 [print] Kyc Status changed from NotStarted to Accepted.Reason: Output Address AddressLine : 6927 14TH AVE

But I would like to only make assertion to match part of the response. e.g.: "Kyc Status changed from NotStarted to Accepted."

1 Answers

The following examples should solve your problem:

    Scenario: Matching text
      * def yourResponse = "12:10:33.960 [print] Kyc Status changed from NotStarted to Accepted.Reason: Output Address AddressLine : 6927 14TH AVE"
      * match yourResponse contains "NotStarted to Accepted"
      * match yourResponse !contains "does not contain"
      * assert new RegExp("NotStarted to Accepted").test(yourResponse)

Needless to say, that you can use any regex with the assert new RegExp construct.

Related