Reputation: 91
According to documentation - response is automatically available as a JSON, XML or String object depending on what the response contents are.
In my case I have the response with content type as text/plain
My server response is
["a.b.c:must match \"(\\d{4}(0[1-9"]
This works where I convert the string to response and then verify (I have escaped all the backslash)
* string responseString = response
* match responseString contains '["a.b.c match \\"(\\\\d{4}(0[1-9"]'
This fails. When response is also available as string then why is this failing
* match response contains '["a.b.c match \\"(\\\\d{4}(0[1-9"]'
com.intuit.karate.exception.KarateException: path: $[*], actual: ["a.b.c match \"(\d{4}(0[1-9"], expected: '["a.b.c:must match \"(\d{4}(0[1-9"]', reason: actual value does not contain expected
Upvotes: 3
Views: 965
Reputation: 58058
Please paste the below into a fresh Scenario and see it working for yourself. It should help you resolve your problem:
* string response = '["a.b.c:must match \"(\\d{4}(0[1-9"]'
* match response contains '["a.b.c:must match \"(\\d{4}(0[1-9"]'
* assert response.contains('["a.b.c:must match \"(\\d{4}(0[1-9"]')
Upvotes: 1