I want to compare two nested json response, so i am using "contains deep". But while comparison i want to ingnore some fields(skip comparison on those fields).
Example: I want to ignore the state field while comparing both response given below.
Scenario1:
* def response1 = { id: 1, name: 'John', address: { city: 'New York', state: 'NY' } }
* def response2 = { id: 1, name: 'John', address: { city: 'California', state: 'CA' } }
* match response1 contains deep response2
# Note: My requirement is tp show difference of city only as state i want to ignore in the karate report
Scenario2:
* def response1 = { id: 1, name: 'John', address: { city: 'New York', state: 'NY' } }
* def response2 = { id: 1, name: 'John', address: { city: 'New York', state: 'CA' } }
* match response1 contains deep response2
# Note: My requirement is to show no difference at all as the state node should be ignored in the karate report.
I am not sure what exactly should i try here for ignoring the field. Please help here.
Sorry, Karate doesn't work like that. Teams use it for schema validation like this, and by the way, this is the answer to your "Scenario 2".
What you are asking for can be done by code. Or you are welcome to contribute code to Karate.
Here is how you can re-write Scenario 2: