1

Does karate mock supports contains syntax to match a certain condition?

I have a requirement like if Account Id contains "789" then send the required response file.

I have tried, but facing syntax issue.

def RespFile = (AccountId == "909090" ? 
  'Failure.xml' : 
  (AccountId contains ["359"] ? 'Succes.xml' : 'nomatch.xml'))

Please help me for the above

Giulio Caccin
  • 2,962
  • 6
  • 36
  • 57

1 Answers1

0

No. Use pure JS logic. Or you can try look at the karate.match() API.

Something like this:

* def accountId = 'some string'
* def response = accountId.contains('foo') ? read('foo.json') : {}
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248