Reputation: 85
Is there any way to check if object is empty then ok if not then check if it matches a fixed structure?
I mean, something like:
* def expectedDelayEntries = response.delayEntries == "{}" ? {} : '#(delayEntries)'
Upvotes: 0
Views: 6118
Reputation: 58058
Yes. Refer to the docs: https://github.com/intuit/karate#conditional-logic
Do this in 2 steps.
* def expected = condition ? { foo: '#string' } : { bar: '#number' }
* match response == expected
Upvotes: 2