I am trying to validate an error response body of non-json format. I have tried using the schema as well as a keyword using contains to match. It is not working for me.
Actual Response response returned from API when multiple matches are observed in a post call:
{"error":{"text":SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'NewEmp' for key 'employee_name_unique'}}
My Karate Feature:
Given url 'http://dummy.restapiexample.com/api/v1/create'
def errResp = "error"
And request {"name":"Hello1","salary":"123","age":"23"}
When method POST
Then status 200
Then match $ contains error #not working
Then match $ contains errResp #not working
Tried * match actual[0] == '#(^partSchema)' too from https://gist.github.com/ptrthomas/2a1e30bcb4d782279019b3d5c10b3ed1 . Not working
Please understand type-conversions first: https://github.com/intuit/karate#type-conversion
Then convert the response to a string before you want to do string contains checks: