0

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)'
krlzlx
  • 5,752
  • 14
  • 47
  • 55

1 Answers1

1

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
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248