I'm writing features for a Karate Netty mock service and I'm trying to use the Scenario to match on a key value pair in the request.
For example:
In a request like this one that has a nested array of objects, I want this feature to fire when any of the Id values are null:
{
"Array": [
{
"Id": "legitId"
},
{
"Id": null
}
],
}
Scenario: pathMatches('path/to/my/endpoint') && methodIs('post') && request.Array.contains('Id': null)
The documentation says I can use JS expressions in the scenario, but I've had a lot of trouble finding something that nashorn can parse that can do this. I've tries JSON.stringify and indexOf, some, the syntax used in matching in a karate test, still no luck. I also tried using a wildcard for the Array index to say something like Array[*].Id == null, but that doesn't fly either.