Lets say we scripted the scenarios following way for our evolving servers
Actual server v1 response
response = { id: "1", name: "karate" }
Mocking client v1 schema
schema = { id: "#string", name: "#string }
* match response == schema
Actual server v2 response
response = { id: "2", name: "karate", value: "is" }
Mocking client v2 schema
schema = { id: "#string", name: "#string, value: "#string" }
* match response == schema
Actual server v3 response
response = { id: "3", name: "karate", value: "is", description: "easy" }
Mocking client v3 schema
schema = { id: "#string", name: "#string", value: "#string", description: "#string" }
* match response == schema
Similarly for backward compatibility testing of our evolving servers, we script the scenarios following way
Actual server v3 response
response = { id: "3", name: "karate", value: "is", description: "easy" }
Mocking client v1 schema
schema = { id: "#string", name: "#string }
* match response contains schema
Actual server v2 response
response = { id: "2", name: "karate", value: "is" }
Mocking client v1 schema
schema = { id: "#string", name: "#string }
* match response contains schema
Actual server v1 response
response = { id: "1", name: "karate" }
Mocking client v1 schema
schema = { id: "#string", name: "#string }
* match response contains schema
Proposal is to be able to use some kind of flag in match statement that dynamically decides the kind of match we do during testing. Lets say that the name of flag is SOMEFLAG and we provide the kind of match we want to do during testing (set in karate-config.js for global effect)
var SOMEFLAG = "contains";
OR
var SOMEFLAG = "==";
Now in scenario we do following
# Depending on what is set in karate-config.js, it will use either contains or == for verification.
* match response SOMEFLAG schema
Is it possible to do this in karate ?
Also note that success of this idea really depends on https://github.com/intuit/karate/issues/826 due to ability match nested object using contains match.